1753797 Members
7546 Online
108805 Solutions
New Discussion юеВ

FTP through script

 
Panpalia
Occasional Advisor

FTP through script

Hi,
Please ignore my knowledge,I am very new to Unix
I am running following code to perform ftp from remote machine.
but i am getting an error -test1: Syntax error at line 4 : `<<' is not matched
please see the code -
ftpthefile()
{
ftp -n < open 10.158.19.136
user gbx wbo\$2008
get /dnbusr1/gbx/audit/gb200804.txt /dnbusr1/gbx/gb200804.txt
bye
EOT
}
exit 0
5 REPLIES 5
john korterman
Honored Contributor

Re: FTP through script

Hi,

check for spaces in front of the "second" EOT
They are not allowed.

regards,
John K.
it would be nice if you always got a second chance
James R. Ferguson
Acclaimed Contributor

Re: FTP through script

Hi:

Make sure that your end-of-file marker (the 'EOT' word) is flush left without leading whitespace.

You may use leading *tab* characters only if you use '-<
Regards!

...JRF...
Victor Fridyev
Honored Contributor

Re: FTP through script

This works:
#!/usr/bin/sh
ftpthefile()
{
ftp -n <open 10.158.19.136
user gbx wbo\$2008
get /dnbusr1/gbx/audit/gb200804.txt /dnbusr1/gbx/gb200804.txt
bye
EOT
}
ftpthefile
exit 0

BTW, I'd prefer to use .netrc:

machine flinux1
login admin
password Adm1n
macdef init
ascii
by
quit

Between macdef init and by you can put all needed commands and run just
ftp flinux1
by the user in whos homedir you have such .netrc

HTH
Entities are not to be multiplied beyond necessity - RTFM
Steven Schweda
Honored Contributor

Re: FTP through script

And, if all you wish to do is fetch a file,
you might find wget easier to use.

http://www.gnu.org/software/wget/wget.html
Panpalia
Occasional Advisor

Re: FTP through script

Thanks everyone!!