Sponsored Content
Top Forums Shell Programming and Scripting Problem in Downloading one day old files from FTP site Post 302279333 by shekhar_v4 on Thursday 22nd of January 2009 12:31:07 PM
Old 01-22-2009
Hi,

I'm using the first approach fetching filenames and then determining files which I need to fetch.

I'm connected to the FTP and by using ls -l listing the filenames to local file. And then I'm doing some formatting and removed more than one day old files names. I have done while loop on the filesnames and prepared a string of file names and using that string to get files from FTP site.

I have given final command as
mget "abcd.txt" "efgh.txt" "ijkl.txt"

But this command pulling all the files from the directory.

I tried get command, but its not working.

my script looks like below.

**********************
#! /bin/ksh

printf "open $HOST \n" > ftp.cmd
printf "user $USER $PASSWD\n" >> ftp.cmd
printf "bin\n" >> ftp.cmd
printf "cd Models\n" >> ftp.cmd
printf "prompt\n" >> ftp.cmd
printf "ls -l excel_list.txt\n" >> ftp.cmd
printf "bye\n" >> ftp.cmd
ftp -n < ftp.cmd
rm *.cmd

sed 's/\(01-06-09\.[a-zA-Z0-9_]*\)/\
\1\
/g' excel_list.txt|grep '^01-20-09' >> listDates1.txt

sed 's/[0-9][0-9]-[0-9][0-9]-[0-9][0-9].*[0-9][0-9]:[0-9][0-9][A-Z][A-Z]/ /g' listDates1.txt >> listDates2.txt

sed 's/^ *//g' listDates2.txt >> listDates3.txt

sed 's/^[0-9][0-9]*//g' listDates3.txt >> listDates4.txt

sed 's/^ *//g' listDates4.txt >> excel_files.txt

FTP_LIST=''
while read files
do
FTP_LIST=$FTP_LIST'"'$files'" '
done < "excel_files.txt"

printf "open $HOST \n" > ftp.cmd
printf "user $USER $PASSWD\n" >> ftp.cmd
printf "bin\n" >> ftp.cmd
printf "cd Models\n" >> ftp.cmd
printf "prompt\n" >> ftp.cmd
printf "get $FTP_LIST\n" >> ftp.cmd
printf "bye\n" >> ftp.cmd
ftp -n < ftp.cmd
rm *.cmd
*********************

Can you suggest how get selected files using FTP.

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pulling a list of files from FTP site in a shell script

Hi, I am writting a shell script which will pull a list files (mentioned in one file 1.txt) from external FTP site (for ex: ftp://abcd.efghijk.com/). The 1.txt is in my local unix directory. I have username and password to connect the external FTP site. Also before I pull the files, I need... (0 Replies)
Discussion started by: spatra
0 Replies

2. Shell Programming and Scripting

script for download files from ftp site

I'm new to scripting. I'm trying to write a script to download files from ftp site, the following is the script and the message i get after running the script. no files were downloaded :( Thanks advance! script: #!/usr/bin/ksh DAY=`date --date="-1 days" +%y%m%d` ftp -v -n "ftp.address" <<... (5 Replies)
Discussion started by: tiff-matt
5 Replies

3. Shell Programming and Scripting

Download previous day files through FTP

Hi All, I have a scenario where I need to download the previous day modified files from other server to my server through FTP . Could any one please send me the shell script for the same. I used the following but I dont know how to proceed after this. ftp -n -i -v $IP <<ENDOFinPUT >>... (3 Replies)
Discussion started by: sarathchandrach
3 Replies

4. Shell Programming and Scripting

shell script - ftp downloading serveral files without mget

Hello guys, i'm searching for a solution how to download all files from root-directory of an ftp-server through an ftp proxy getting through the ftp proxy and download one file with get ist no problem, but mget * does nothing! ftp -n -i -v <<EOF open proxyHost proxyPort user... (19 Replies)
Discussion started by: macProgger23
19 Replies

5. Shell Programming and Scripting

Expect - get, then move files within FTP site?

Trying to do the following, and it looks like Expect is probably my best bet. Any help greatly appreciated 1) Log onto ftp site 2) Go to folder 3) GET all files matching basename*.txt 4) MOVE those files to a subfolder on the ftp site. I don't need to move it on MY computer, I want to move... (2 Replies)
Discussion started by: mbourgon
2 Replies

6. Shell Programming and Scripting

Downloading FTP Files

Hi every one, I have the requirement to download the files from FTP and move those files to unix box. Once after coping the files, i need to remove the files in FTP. I'm a newbie in Unix script. Can you please suggest a script for this.. Thanks in advance.. (2 Replies)
Discussion started by: Murali4u
2 Replies

7. Shell Programming and Scripting

Batch downloading images from a site.

So there is a forum thread (with 100+ pages)where people have posted images, which on a 3rd party site like imgur or imageshack. I'm trying to download all those images. I tried wget -r -l1 --no-parent -nH -nd -P/tmp -A".gif,.jpg" LINK but this doesn't download it. Does anything know a... (1 Reply)
Discussion started by: Howkisl
1 Replies

8. UNIX for Dummies Questions & Answers

current day remote files from FTP

Hi All, I have to work on a korn shell script to pick up only the current day files dropped on the remote server (using ftp). The file do not have daytimestamp on it. It has to be based on server time (AIX) The file naming convention is "test_file.txt" When I log in into the ftp account... (15 Replies)
Discussion started by: pavan_test
15 Replies

9. SCO

FTP problem with site exec command

Hello dear Users, I am for the first time in this forum. I come from Germany. Please excuse my bad englisch. My OS is SCO open Server Release 5. I have a problem whith FTP and the command "site exec" if I use the command "ftp> site chmod 777 /tmp/startkpf.sc 200 CHMOD command successful. ... (8 Replies)
Discussion started by: fla5do
8 Replies

10. Shell Programming and Scripting

To merge files on FTP site before getting them

I have a job that connects to FTP site, rename, get, delete a file and then process it. The renaming is done in consideration of this is one file name into which data is being accumulated many times within 24 hour cycle. This is what happens now: ftp -i $FTPHOST <<-EOF ren... (3 Replies)
Discussion started by: migurus
3 Replies
SIMPLEFTP(1)						    InterNetNews Documentation						      SIMPLEFTP(1)

NAME
simpleftp - Rudimentary FTP client SYNOPSIS
simpleftp url [...] DESCRIPTION
simpleftp is a Perl script that provides basic support for fetching files with FTP in a batch oriented fashion. It takes one or more FTP URLs on the command line. The file(s) will be retrieved from the remote server and placed in the current directory with the same basename as on the remote; e.g., <ftp://ftp.isc.org/pub/usenet/CONFIG/active.gz> is stored as active.gz in the current directory. The script properly understands usernames, passwords and ports specified as follows: ftp://user:password@host:port/path/file BUGS
simpleftp is an extremely poor substitute for more complete programs like the freely available wget or ncftp utilities. It was written only to provide elementary support in INN for non-interactive fetching of the files in <ftp://ftp.isc.org/pub/pgpcontrol/> or <ftp://ftp.isc.org/pub/usenet/CONFIG/> without requiring administrators to install yet another package. Its shortcomings as a general purpose program are too numerous to mention, but one that stands out is that downloaded files by simpleftp override existing files with the same name in the local directory. HISTORY
Tossed off by David C Lawrence <tale@isc.org> for InterNetNews. Rewritten to use "Net::FTP" by Julien Elie. $Id: simpleftp.pod 8357 2009-02-27 17:56:00Z iulius $ SEE ALSO
actsync(8). INN 2.5.2 2009-05-21 SIMPLEFTP(1)
All times are GMT -4. The time now is 02:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy