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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ftp script

Status
Not open for further replies.

mariocq

MIS
Apr 20, 2001
61
US
Hello:

Does any you if there are any script that allows to automate the upload of files to a list of unix servers?


Regards,
Mario.
 
Have you tried a keyword search ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Mario,

Check into a program called 'expect'. Basicially it is a script language that allows you to automate tasks which require different responses based upon a programs output. I use it for ftp uploads/downloads because it can wait for specific strings and then send a response back. Seems with ftp you can't redirect input, because ftp seems to lose the buffered input (something like that). You can setup timeout periods and responses based upon various outputs from the program your running. You can react differently based upon successfull or unsuccessful errors.

Once you have the script running you can trigger it with cron or almost anything.

You may have it already, if not let me know I and see if I can find where you can download it from.

Lee
 
Here is a simple ksh one. Just make the address a variable,and loop through all your servers. Mind you it is not very secure. The <<! says input all the lines till you hit !, into the ftp.


#!/bin/ksh
ftp -n 10.201.2.50 <<!
user username password
mkdir 123
quit
!
 
I do something similar with a servers.txt and all the servers setup in .netrc. I only need to ftp a single file to multiple servers. Hope this helps.

#/usr/bin/ksh

LIST=/your/path/servers.txt
LOG=/your/path/ftp.log

while read HOST
do
/usr/bin/ftp -iv >> $LOG <<END_FTP
open $HOST
put yourfile
END_FTP
done < $LIST

This is from memory, I might have missed something.

Boot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top