SHELL SCRIPT TO FTP 100s OF FILES.

Hi everyone,
I want to write a shell script that will ftp over 300 files from a remote server. Can someone please help me with this? I do have a list of the names and here is an example of them.

 20060111084957_99
 20060815162600_99
  20060815162627_01
  20060815162717_01
jkopokuAsked:
Who is Participating?
 
Kent OlsenConnect With a Mentor Data Warehouse Architect / DBACommented:

If your ftp doesn't support mget, make a small shell procedure based on the example of Tintin.

# !/bin/sh
##  fget -- automatic procedure to get a file via ftp
#    usage:  fget {source} [dest]

ftp -n  <FTP server> <<EOF
user login password
prompt
get $1 $2
quit
EOF
# end of procedure


Then execute a small loop to fget each of the files.  The file "filelist" contains the list of files that you want to fetch.

cat filelist | while read fn; do fget $fn; done


Good Luck,
Kent
0
 
yuzhCommented:
Your FTP server OS version please, (need to know if your OS support mget or not).

Are the files in the same dir?

Why not put all the files in a tar ball and transfer the tar ball accross.
(you can run tar command locally in the FTP server or use ssh to run it remotely).

Plain text FTP is insecure, consider use secure ftp (sftp, comes with secure shell) to
transfer files.

Here're some example script for FTP file(s)
http:Q_21056387.html
http:Q_20702441.html   (in your case, use "get" instead of "put" for FTP).
0
 
TintinConnect With a Mentor Commented:
# !/bin/sh
cd /path/to/store/files

ftp -n  <FTP server> <<EOF
user login password
prompt
mget 2006*
quit
EOF


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.