Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SHELL SCRIPT TO FTP 100s OF FILES.

Posted on 2006-11-15
3
Medium Priority
?
2,625 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:jkopoku
3 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 17952008
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
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 500 total points
ID: 17952928
# !/bin/sh
cd /path/to/store/files

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


0
 
LVL 46

Accepted Solution

by:
Kent Olsen earned 500 total points
ID: 17955637

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question