#!/bin/bash PATH=@EMC2_BIN_DIR@:$PATH REALTIME=@REALTIME@ THIS=$(basename $0) export HAL_RTMOD_DIR=@EMC2_RTLIB_DIR@ help () { halcmd -h cat <" exit 1 fi # filename can be specified two ways: # as parameter for -f ('f filename') # or as trailing parameter if [ $# -gt 0 ] ; then if [ "X$filename" = "X" ] ; then filename=$1 shift else echo "$THIS: Error: Specified '-f $1' and also <$filename>" exit 1 fi fi if $REALTIME status > /dev/null; then echo "$THIS: Realtime already running. Use 'halrun -U' to stop existing realtime session." 1>&2 exit 1 fi HAVEFILE=false IS_HALTCL=false case $filename in *.hal) HAVEFILE=true if [ -n "$inifile" ] ; then theargs="$theargs -i $inifile" fi # halcmd uses all $theargs: set -- "$theargs -f $filename";; *.tcl) HAVEFILE=true IS_HALTCL=true # haltcl uses only -i arg if [ -n "$inifile" ] ; then tclargs="-i $inifile" else tclargs="" fi # haltcl only uses inifilename and filename: set -- "$tclargs $filename";; "") # for nil filename, support interactive halcmd # or haltcl if -T was used if [ "$INTERACTIVE" != "haltcl" ] ; then INTERACTIVE="halcmd $theargs -kf" fi ;; *) echo "$THIS: Unknown file extension for filename=<$filename>" exit 1 ;; esac case "$INTERACTIVE" in halcmd*) if [ -n "$inifile" ] ; then INTERACTIVE="$INTERACTIVE -i $inifile" fi ;; haltcl) if $IS_HALTCL ; then if [ "$theargs" != "" ] ; then echo "$THIS: args not accepted for haltcl <$theargs>" exit 1 fi else # allowed -T (tcl interactive) with startup .hal file : fi if [ -n "$inifile" ] ; then INTERACTIVE="haltcl -i $inifile" fi ;; esac $REALTIME start || exit $? if $HAVEFILE ; then if $IS_HALTCL; then haltcl $@; result=$? else halcmd $@; result=$? fi fi if [ ! -z "$INTERACTIVE" ]; then $INTERACTIVE; fi halcmd stop || result=$? halcmd unload all || result=$? $REALTIME stop || result=$? exit $result