I have a korn script that does this:
testing.ksh:
m_Ftp -t'echo "No skipping"' -f DEV_OVR MMMM <<!
lcd ${REMOTE_DIR}
pwd
cd ${DEST_DIR}
ls
put test11.txt
bye
!
This calls another script that gets options (if there) and assigns the variables as expected. However, for some reason it's doing this:
m_Ftp in other script that is called:
# Get argument (-f "DEV_OVR")
ARGVAL=""
DEVCMD=""
while getopts f:t: opt; do
case $opt in
# Oracle ID
f) ARGVAL="$OPTARG"; shift;; #should be "No skipping"
t) DEVCMD="$OPTARG"; shift;; #should be DEV_OVR
?) ;;
esac
done
echo "0:" $0
echo "1:" $1
echo "2:" $2
echo "3:" $3
echo "Argval:" $ARGVAL
echo "DEVCMD:" $DEVCMD
#different
M_SITE_NAME="$2"
echo "M_SITE_NAME:" $M_SITE_NAME
Output:
0: m_Ftp
1: -f #expect MMMM
2: DEV_OVR
3: MMMM
Argval:
DEVCMD: echo "No skipping"
M_SITE_NAME: DEV_OVR #should be MMMM
I need this to work so it FTP's to the correct location, MMMM, regardless of what options are given.
I've tried getting rid of the space between -f and DEV_OVR in testing.ksh, and this is the output, which gets the site right, but isn't showing the correct content for DEVCMD or Argval:
0: m_Ftp
1: -fDEV_OVR
2: MMMM
3:
Argval:
DEVCMD: echo "No skipping"
M_SITE_NAME: MMMM
M_FTP_SITE here: MMMM
How do I get SITE, devcmd, and argval to show correctly? The last script version didn't have devcmd provided in the argument list, and was getting the site name from $1, not $2, but when I printed argval, it wasn't showing correct.