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 Script

Status
Not open for further replies.

ryanc2

MIS
Apr 18, 2003
73
US
I need to FTP multiple files with the filenames contained in a list. I need to make one connection, so looping through the list and ftp'ing each file is not an option. I tried something like this, but cat doesn't read the contents like I need.

#!/bin/ksh
list=`cat list.txt`
if [ -s list.txt ]; then
ftp -ndi ${IP} <<-! > ftp.log 2>/dev/null
user ${user} ${pwd}
bin
cd ${rdir}
mput ${list}
bye
!
fi

Thanks in advance...
 
try something like this - assuming 'list.txt' contains ONE file to be transfered per line:

Code:
#!/bin/ksh

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

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
That works like a charm - THANKS. One last thing, what about reanaming all the files that I sent to .done on the remote server?
 
Code:
#!/bin/ksh

if [ -s list.txt ]; then
    ftp -ndi ${IP} <<-! > ftp.log 2>/dev/null
         user ${user} ${pwd}
         bin
         cd ${rdir}
         $(sed -e 's/.*/put & &.done/g' list.txt)
         bye
     !
fi

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top