Hi All,
I am writing a script to pass the getopts argument to the function which I have. But it as soon as I execute the script, the argument is taking it as blank. I tried using multiple way to check but its not working.
Can someone please let me know what wrong in this code.
function1()
{
processing details
wget -i $base_dir/$APPNAME.txt --directory-prefix=downloads --http-user=$SVN_USR --http-password=$SVN_PASS -o $base_dir/$APPNAME.log
}
while getopts ":ackpsuv" OPT; do
case "$OPT" in
a) APPNAME=$OPTARG;;
c)
echo ;;
k) KEYSTOREPSSWD="$OPTARG;;
p) SVN_PASS="$OPTARG;;
s)
uploadSVN
;;
u) SVN_USR=$OPTARG;;
v) KEYSTORE=$OPTARG;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
if [ -z "${APPNAME}" ] && [ -z "${SVN_USR}" ] && [ -z "${SVN_PASS}" ]
then
function1 ${APPNAME} ${SVN_USR} ${SVN_PASS}
else
echo "Check usage"
fi
As you can see, none of the variables are being taken by the function.
execution output
$ksh -x test.ksh -a "appname" -u "user" -p "pass"
+ getopts :ackpsuv OPT
+ APPNAME=''
+ getopts :ackpsuv OPT
+ [ -z '' ]
+ [ -z '' ]
+ [ -z '' ]
+ [ -z '' ]
+ echo 'Downloading the required perevious year files from SVN Repo..'
+ wget -i ./.txt --directory-prefix=downloads --http-user= --http-password= -o ./.log
+ grep 'Authorization failed.' ./.log
+ wc -l
+ error=0
+ [[ 0 -ne 0 ]]
+ tail -1 ./.log
+ cut '-d ' -f2
+ completed=URLs
+ [[ URLs -ne 6 ]]
+ echo 'All the required files not downloaded! Please check.'
All the required files not downloaded! Please check.
+ exit 3
Please can someone help me in this case?
Regards
Sid