1751935 Members
4885 Online
108783 Solutions
New Discussion юеВ

Re: ftp script !

 
Ivan Azuara
Regular Advisor

ftp script !

Hi !

I'm testing the next ftp script:

for x in ` cat /sort/LOGS_CRONTAB/logs_home/logs_opers `
do
cd /
cd /sort/LOGS_CRONTAB/logs_home/depot_logs/$x/July04
ftp -i -n 130.10.17.18 < user cencom1 cencom1
cd s_inb_01/$x/Julio04
mput *
EOF
done
echo Transfer succesfull | mailx -s "Transfer OK" support@banamex.com

When i execute this shell script, i receive the next message:

# ftp_test
ftp_test: Syntax error at line 5 : `<<' is not matched.

Is very strange because if i write line by line in the command prompt. The script runs good.

Somebody have an idea about this error ?


Thank's in advance !
"Enjoy the life .."
6 REPLIES 6
Steven E. Protter
Exalted Contributor

Re: ftp script !

All I can do is give you working code which will look alot like what you have.

ftp -nv ${SERVER} << FTPEOF > /tmp/temp_log.$$
user ${USERNAME} ${PASSWORD}
#Get file
get $1
quit
FTPEOF

Put this in the do/done loop and it should work.

mput versus get should not make a difference.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
john kingsley
Honored Contributor

Re: ftp script !

Make sure your don't have spaces or tabs in the lines between <
Muthukumar_5
Honored Contributor

Re: ftp script !

Hai,

Shell will prompt if use the <
A good sample script is avaible at http://www.aplawrence.com/SCOFAQ/FAQ_scotec6autoftp.html

Easy to suggest when don't know about the problem!
Dan Martin_1
Frequent Advisor

Re: ftp script !

That script should work if you are in Posix or Korn shell. What is the default shell of the account you are running this from?

Dan
Ivan Azuara
Regular Advisor

Re: ftp script !

Hi !

I probed yours suggestions, but any works (the sintax error message doesn├В┬┤t disappearing). I use an other form to make the ftp connection, and works fine:

(echo "open 130.10.17.18
user $user $password
cd s_inb_01/$x/July04
mput *
close "
) | ftp -i -n

Best Regards
"Enjoy the life .."
Muthukumar_5
Honored Contributor

Re: ftp script !

Hai,

The problem is only because of -EOF. Try to use the following script as,

------- ftp.ksh ---------
#!/usr/bin/ksh
set -x

for x in `cat /sort/LOGS_CRONTAB/logs_home/logs_opers`
do
ftp -i -n 130.10.17.18 <<-EOF 2>/dev/null
user cencom1 cencom1
lcd sort/LOGS_CRONTAB/logs_home/depot_logs/$x/July04
cd s_inb_01/$x/Julio04
mput *
bye
EOF
done
[[ $? -eq 0 ]] && echo Transfer succesfull | mailx -s "Transfer OK" support@banamex.com

#normal return
exit 0

-------------------------------

Execute it. It will surely work.
Easy to suggest when don't know about the problem!