From 19a9467a9e1b450b104746cc911bdb1a98b1acff Mon Sep 17 00:00:00 2001 From: Ray Kinsella Date: Mon, 5 Sep 2016 13:41:05 +0100 Subject: vpp-userdemo: adding debug option Adding -d debug option to capture vpp-userdemo output to log file. This will aid debug down the line. Change-Id: Iaad69ad8890cafb9b748e3629447d9e6061a91f6 Signed-off-by: Ray Kinsella --- vpp-userdemo/vmrun | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'vpp-userdemo') diff --git a/vpp-userdemo/vmrun b/vpp-userdemo/vmrun index 25c674e..8e80856 100755 --- a/vpp-userdemo/vmrun +++ b/vpp-userdemo/vmrun @@ -12,19 +12,39 @@ # See the License for the specific language governing permissions and # limitations under the License. +OPTIND=1 # Reset in case getopts has been used previously in the shell. + +function show_help { + echo -e "$0:" + echo -e "\t-h displays this help message" + echo -e "\t-d logs output to a file $0-.log" +} + if [ $USER != "root" ] ; then #echo "Restarting script with sudo..." sudo $0 ${*} exit fi -if [ -z "$1" ]; then +while getopts "h?d" opt; do + case "$opt" in + h|\?) show_help + exit 0 + ;; + d) exec &> >(tee -a "$0-$$.log") + ;; + esac +done + +shift $((OPTIND-1)) + +if [ -z "$@" ]; then echo "You must specify a demo name" exit 0; fi -if [ -f "$1" ]; then - DEMO=$1 +if [ -f "$@" ]; then + DEMO=$@ else echo "This is not a valid filename" exit 0; @@ -63,7 +83,7 @@ if [ -e $DEMO.cmd ]; then rm $DEMO.cmd fi -#Loop through instructions and commands from filename input as $1 +#Loop through instructions and commands from filename input as $@ for ((i=0;i<${#INSTR[@]};++i)); do instruction "\${INSTR[i]}" "\${CMD[i]}" eval "${CMD[i]}" -- cgit 1.2.3-korg