I have this issue that I can't resolve and need help on.
Currently I can kick off the script 2 two ways:
with 4 args like:
scan_n_cktrl.sh F133 2 5 915
OR
scan_n_cktrl.sh -f F133 -r 2 -w 5 -t 915
But I can't combine 2 methods together to kick the scrip like this
scan_n_cktrl.sh F133 2 -w 5 -t 915
it seems like the option w and t doesn't work. Any idea why?
Here are my test code below:
FILENAME=$1
TIME_FILE=$2
while getopts ":w:t:" opt; do
case $opt in
w) WORKDAY=$OPTARG;;
t) TIME_FILE=$OPTARG;;
\?) show_usage ;;
esac
done
echo "$FILENAME and $TIME_TRL"
echo "WORKDAY:$WORKDAY"
echo "TIME_FILE=$TIME_FILE"
=== Result ====
+ getopts :w:t: opt
+ FILENAME=F133
+ TIME_TRL=2
+ echo F133 and 2
F133 and 2
+ echo WORKDAY:
WORKDAY:
+ echo TIME_FILE=
TIME_FILE=
Currently I can kick off the script 2 two ways:
with 4 args like:
scan_n_cktrl.sh F133 2 5 915
OR
scan_n_cktrl.sh -f F133 -r 2 -w 5 -t 915
But I can't combine 2 methods together to kick the scrip like this
scan_n_cktrl.sh F133 2 -w 5 -t 915
it seems like the option w and t doesn't work. Any idea why?
Here are my test code below:
FILENAME=$1
TIME_FILE=$2
while getopts ":w:t:" opt; do
case $opt in
w) WORKDAY=$OPTARG;;
t) TIME_FILE=$OPTARG;;
\?) show_usage ;;
esac
done
echo "$FILENAME and $TIME_TRL"
echo "WORKDAY:$WORKDAY"
echo "TIME_FILE=$TIME_FILE"
=== Result ====
+ getopts :w:t: opt
+ FILENAME=F133
+ TIME_TRL=2
+ echo F133 and 2
F133 and 2
+ echo WORKDAY:
WORKDAY:
+ echo TIME_FILE=
TIME_FILE=