1834636 Members
3619 Online
110069 Solutions
New Discussion

Re: FTP question

 
SOLVED
Go to solution
Patrice Blanchard_2
Frequent Advisor

FTP question

Hi,

is it possible to get a specific range of files through FTP from a HP-UX script?

Ex:

CURDATE=`date '%m%d%y'`
ftp -i -n IP_ADDRESS > /baan4/plc_data/data/ftp.log << EOF
user login password
ascii
get *$CURDATE.csv
bye
EOF

All i want to do is fetch the files that got the current date in the name. (file_23032005.csv)

i have a scipt that is working but it's always getting the same file (*.csv). I want to be able to pass the file name as a parameter to it.

regards

PB
5 REPLIES 5
Jim Mallett
Honored Contributor

Re: FTP question

A get alone will just grab the first file it finds I believe. Try changing that to an mget (multiple get) and it should work fine. I just tried it out successfully.

Jim
Hindsight is 20/20
Wilfred Chau_1
Respected Contributor
Solution

Re: FTP question

add prompt after ascii
and replace get with mget "$CURDATE.csv"

then, try again.

Madhukar Adi
New Member

Re: FTP question

you need to do a mget inorder to download multiple files. Replace your get statement with mget *$CURDATE.csv, Also do a prom before or after ascii...

user login password
prom
ascii
mget *$CURDATE.csv
Jim Mallett
Honored Contributor

Re: FTP question

I'm not sure if the above was an example or the actual script and filenames, if so there are a couple of minor changes.

Your file example is file_23032005.csv (mmddyyyy) so:
CURDATE=`date +%d%m%Y`

And as mentioned above, get becomes mget:
mget *$CURDATE.csv

On SYS2 I created afile_23032005.csv, bfile_23032005.csv, and cfile_23032004.csv (notice the year on the last one).

The following grabbed the first two:
CURDATE=`date +%d%m%Y`
ftp -i -n 10.10.2.110 > /tmp/ftp.log << EOF
user user pass
ascii
mget /tmp/*$CURDATE.csv
bye
EOF

Hindsight is 20/20
Patrice Blanchard_2
Frequent Advisor

Re: FTP question

Thanks, it's working.

regards

PB