Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP via a script 2

Status
Not open for further replies.
Feb 20, 2002
265
GB
Hi all

I have a script that makes a backup (and log) of a work directory on our Sun box. I want to add to the script a FTP transfer onto another machine (for backing up)

I don't really know where to start, any help would be great.

Thanks, Simon
 
As a starting point you need to set up a .netrc file to allow unattended remote ftp's See the man page on netrc

 
More info

Set up your .netrc file in your home directory

machine <machine name> login <login name> password <password>

.netrc must have 600 permissions

Then in your transfer script put :-

ftp << EOF
bin
cd <directory name>
put <filename>
EOF



hope this helps you.
 
Alternatively, use something like:

ftp -n << EOF
open <IP Address>
user <username> <password>
bi - if necessary
send <filename>
bye
EOF

I have a similar script in crontab to do the same job as your require, ie create a security copy on another machine.

Hope this helps.
 
Sorry - my 'Alternatively' above was obviously written at the same time as trunix' second response. Cheers.
 
Check out the FAQ's under the general Unix discussions. There are several FAQ's devoted to FTP automation.

-Danny
dan@snoboarder.net






 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top