Operating System - HP-UX
1827889 Members
1829 Online
109969 Solutions
New Discussion

Re: Using tftp/ftp in a shell script

 
Pat_52
Occasional Contributor

Using tftp/ftp in a shell script

How can the "tftp" or "ftp" command be used in a shell script? I would like to create a script that would automaticaly send some files/directories to a FTP server.

Thanks
9 REPLIES 9
James R. Ferguson
Acclaimed Contributor

Re: Using tftp/ftp in a shell script

Hi Pat:

There are dozens upon dozens of posts in this Forum dealing with this. Do a search on 'ftp and script'.

Regards!

...JRF...
Pete Randall
Outstanding Contributor

Re: Using tftp/ftp in a shell script

Pete Randall
Outstanding Contributor

Re: Using tftp/ftp in a shell script

Sorry,

"may" help not "my" help

Pete
Steve Steel
Honored Contributor

Re: Using tftp/ftp in a shell script

Jose Mosquera
Honored Contributor

Re: Using tftp/ftp in a shell script

Hi,

This example do a multiple get (mget) in ascii mode and not asking from 192.4.12.5 You can put the host alias instead IP address

echo "open 192.4.12.5\n user \n ascii\n prompt\n mget \n bye"|ftp -v -n


Rgds.
Jannik
Honored Contributor

Re: Using tftp/ftp in a shell script

if i where you i would use ssh and scp.

remote command:
ssh -c "command"
scp ./ @

you just have to have the keyes in place, developers hate it in the beginning, but they will come to love it :-).

/Jannik
jaton
Chris Vail
Honored Contributor

Re: Using tftp/ftp in a shell script

Like others posted, there are dozens of threads on this subject in ITRC to research. However, let me point out that ftp and tftp are not designed to be used in a script, and doing so just gets ugly.
I recommend using rcp (remote copy) for unsecure systems, and scp (secure copy) for for more secure systems. These are much more easily scripted, easier to use and debug. There are also lots of threads on these two utilities here in ITRC, just look 'em up.


Good Luck
Chris
Stanimir
Trusted Contributor

Re: Using tftp/ftp in a shell script

For example:
1.Create file like this
arg.ftp:
user
cd /
lcd /
binary
put
bye
2.Use:
ftp -n < ./arg.ftp
By.
Pat_52
Occasional Contributor

Re: Using tftp/ftp in a shell script

Thanks for the help!