I am working creating a bash shell framework where I need to pass variable number of arguments from one script to another.
Script1.sh
#!/bin/bash
vOut=`sudo -u execuser script2.sh $1 $2 $3`
Script2.sh
ActualScriptName="$2"
Host="$1"
Args="$3"
vOut=`$ActualScriptName -H${HOST} "$Args"
ActualScript3.sh
#!/bin/bash
while getopts ":H:s:e:" OPTION
do
case $OPTION in
T)
HOST=${OPTARG}
;;
s)
START_TIME=${OPTARG}
;;
e)
END_TIME=${OPTARG}
;;
?)
usage
exit
;;
esac
done
echo HOST=$HOST
echo START_TIME=$START_TIME
echo END_TIME=$END_TIME
Now, when I am calling script1.sh:
script1.sh 10.1.1.1 ActualScript1.sh "-s='2015-09-20 02:00' -e='2015-09-20 02:30'"
I am getting output as:
HOST=10.1.1.1
START_TIME='2015-09-20 02:00' -e'2015-09-20 02:30'
END_TIME=
How can I pass this variable number of arguments from script1 for ActualScript1.sh?