andrewm@58: #!/bin/bash andrewm@58: # andrewm@58: # This script runs an already-compiled BeagleRT project on the andrewm@58: # BeagleBone Black. andrewm@58: andrewm@58: BBB_ADDRESS="root@192.168.7.2" andrewm@58: BBB_PATH="~/BeagleRT" andrewm@60: COMMAND_ARGS= andrewm@62: RUN_IN_FOREGROUND=0 andrewm@89: RUN_WITHOUT_SCREEN=0 andrewm@58: andrewm@58: function usage andrewm@58: { andrewm@58: THIS_SCRIPT=`basename "$0"` andrewm@89: echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-fF]" andrewm@58: andrewm@58: echo " andrewm@58: This script runs a previously compiled BeagleRT project on the andrewm@58: BeagleBone Black. The -b option changes the default path, which andrewm@60: is otherwise $BBB_PATH. The -c option passes command-line arguments andrewm@62: to the BeagleRT program; enclose the argument string in quotes. andrewm@89: andrewm@62: The -f argument runs the project in the foreground of the current terminal, andrewm@89: within a screen session that can be detached later. The -F argument runs andrewm@89: the project in the foreground of the current terminal, without screen, so andrewm@89: the output can be piped to another destination." andrewm@58: } andrewm@58: andrewm@58: OPTIND=1 andrewm@58: andrewm@89: while getopts "b:c:fFh" opt; do andrewm@58: case $opt in andrewm@58: b) BBB_PATH=$OPTARG andrewm@58: ;; andrewm@60: c) COMMAND_ARGS=$OPTARG andrewm@60: ;; andrewm@62: f) RUN_IN_FOREGROUND=1 andrewm@62: ;; andrewm@89: F) RUN_WITHOUT_SCREEN=1 andrewm@89: ;; andrewm@58: h|\?) usage andrewm@58: exit 1 andrewm@58: esac andrewm@58: done andrewm@58: andrewm@58: shift $((OPTIND-1)) andrewm@58: andrewm@58: echo "Running BeagleRT..." andrewm@89: if [ $RUN_WITHOUT_SCREEN -ne 0 ] andrewm@89: then andrewm@89: ssh -t $BBB_ADDRESS "screen -X -S BeagleRT quit &>/dev/null; pkill BeagleRT ; sleep 0.5 ; $BBB_PATH/BeagleRT $COMMAND_ARGS" andrewm@89: elif [ $RUN_IN_FOREGROUND -eq 0 ] andrewm@62: then giuliomoro@85: ssh $BBB_ADDRESS "screen -X -S BeagleRT quit &>/dev/null; pkill BeagleRT ; sleep 0.5 ; screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS" andrewm@62: else giuliomoro@85: ssh -t $BBB_ADDRESS "screen -X -S BeagleRT quit &>/dev/null; pkill BeagleRT ; sleep 0.5 ; screen -S BeagleRT $BBB_PATH/BeagleRT $COMMAND_ARGS" andrewm@62: fi