loop()
{
ftp -v -n hostname << EOF
user user pwd
bin
prompt
cd /tmp
mget ${ans_ip}.tar
bye
}
if [[ "$ans_env" = "sandbox" && "$ans_dc" = "dc1" ]]; then
loop
fi
--------------------------------------
Somehow when i execute the script, Im getting following error(s);
./script: syntax error: unexpected end of file
Looks like Iam missing something...Can you guys help/take a look at it..Not sure what is wrong with this code..It works fine upto taking values...afer that I see that error.
Based on the code you've shown, I can see no error.
(substituting ftp... for cat to test...)
echo "Enter ip "
read ans_ip
echo "Enter environment[sandbox/production]"
read ans_env
echo "Enter Datacenter [dc1/dc2]"
read ans_dc
loop()
{
cat << EOF
user user pwd
bin
prompt
cd /tmp
mget ${ans_ip}.tar
bye
EOF
}
if [[ "$ans_env" = "sandbox" && "$ans_dc" = "dc1" ]]; then
loop
fi
Text:
Enter ip
123.123.123.123
Enter environment[sandbox/production]
sandbox
Enter Datacenter [dc1/dc2]
dc1
user user pwd
bin
prompt
cd /tmp
mget 123.123.123.123.tar
bye
/root # echo $?
0