diff options
author | Ray Kinsella <ray.kinsella@intel.com> | 2016-09-05 13:41:05 +0100 |
---|---|---|
committer | Ray Kinsella <ray.kinsella@intel.com> | 2016-09-05 13:41:37 +0100 |
commit | 19a9467a9e1b450b104746cc911bdb1a98b1acff (patch) | |
tree | 74306ace9fed4dd39c661977c5b0c880445d3619 | |
parent | eeecc73b8e7043185cc0ca5ea307c6fd0172cff0 (diff) |
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 <ray.kinsella@intel.com>
-rwxr-xr-x | vpp-userdemo/vmrun | 28 |
1 files changed, 24 insertions, 4 deletions
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-<pid>.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]}" |