Solved

SHELL SCRIPT TO FTP 100s OF FILES.

Posted on 2006-11-15
3
2,620 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 125 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 45

Accepted Solution

by:
Kent Olsen earned 125 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

730 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