Solved

SHELL SCRIPT TO FTP 100s OF FILES.

Posted on 2006-11-15
3
2,621 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.:

707 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