Solved

SHELL SCRIPT TO FTP 100s OF FILES.

Posted on 2006-11-15
3
2,618 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:
Kdo 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now