Hi All,
I need some help with arrays. I need to take input from the user for hostname, username and password until he enters .(dot) or any other character and store the values in the variable array.
I would further connect to the hostname using username and passwd and copy files from server to these machines.
This is what I have come up with so far. Just can't figure out a way of storing values in the array variable. can someone help.
Code:
#!/usr/bin/sh
#Take input from the user
while ["host_name != "."]
do
echo "Please enter the Hostname"
read host_name
echo "Please enter the username"
read username
echo "Please enter the password"
read password
done
#If you have a better way of accepting data from user , would be great!
#storing these variables in array logic here..
#ftp logic as below..
typeset SRCDIR="/root/temp1"
typeset DESTDIR="/root/"
typeset REMHOST="machB"
typeset -i STAT=0
cd "${SRCDIR}"
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Can't cd to ${SRCDIR}" >&2
exit ${STAT}
fi
ftpput.pl -h ${REMHOST} -l ${USER} -p ${PASSWD} -d "${DESTDIR}" -B *
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
mv * "${BACKUP_DIR}/"
STAT=${?}
echo "mv failed; status ${STAT}." >&2
else
echo "FTP failed; status ${STAT}." >&2
fi
exit ${STAT}
Can someone please help me!
Thanks!
nua7