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!

Read filenames from a file and the FTP them

Status
Not open for further replies.

SuaveRick

Programmer
Apr 12, 2004
142
CA
Hi there, I have a .dat file with the names of files in it like so:

/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_094139_373.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_094024_492.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_093921_789.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_093816_381.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_093719_987.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_093625_797.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_093458_908.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_093235_591.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_093051_606.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_092831_946.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_092652_752.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_092523_235.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_092415_005.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_092308_593.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_092202_356.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_092055_057.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_091927_262.log.gz
/opt/cti/GCTI65/logsArchive/log_ivr_tserver/TServer_IVR.092104_091812_526.log.gz

What I need to do is FTP each one of those files over to another box. I can't just FTP the whole dir those files are in because this is a select few that I need. What is the best way to do this? I was thinking of somehow reading the file line-by-line inside the FTP script but I have no idea how to do that.

Thanks!
 
One option is to create a tar/cpio file with all those files and then send one file only.

Another will imply that you search these forums for "FTP" " and "<<"

this will give a list of threads, and one of the first 10 will give you an example that does EXACTLY what you need.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
That's awesome! Thanks for the help!

Can you explaine this to me a little better, I don't grasp what is going on wit this line inside theh ftp commands?

$(sed -e 's/.*/put &/g' list.txt)

taken from:
if [ -s list.txt ]; then
ftp -ndi ${IP} <<-! > ftp.log 2>/dev/null
user ${user} ${pwd}
bin
cd ${rdir}
$(sed -e 's/.*/put &/g' list.txt)
bye
!
fi
 
$() is basically executing the command within and returning the output of that command.

sed is performing a global substitution and placing "put " in from of each line of "list.txt".

man sed will help you (or not!)

Try and execute the script with "ksh -X script" or -x . I think ksh has this function.
This will output each line of the script, and you can see what it is doing.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top