Download the file

Hi!!

I have to download one file from FTP on a daily basis but the file name not constant.

Filename �BRAA.DAILY1.20120326.3456�

BRAA.DAILY1. - constant

20120326 - system date

3456 - random number which will get change every day.

Few sample file names -

BRAA.DAILY1.20120326.3456
BRAA.DAILY1.20120327.2216
BRAA.DAILY1.20120328.4556

I have written shell program but I am getting the error, refer below details -

#!/bin/csh -e
source /users/bahulra/.cshrc
source /users/bahulra/.login

setenv USER user1
setenv PASSWD password
setenv DATADIR /data17/cocht


ftp -in ftp1.ftp123.com  << EndHere
user $USER $PASSWD
binary
get BRAA.DAILY1.`date +"%Y%m%d"`* $DATADIR/BRAA.DAILY1.`date +"%Y%m%d"`*
bye
quit
EndHere

Error is -

BRAA.DAILY1.20120328*: The filename, directory name, or volume label syntax is incorrect.

Plz help!!

Thanks,
Rahul

Try mget rather than get.

1 Like

Take a look at

mget -- to get multiple files with wildcards
prompt -- to use/skip prompting

1 Like

thankx for the reply!!

i tried -

mget BRAA.DAILY1.`date +"%Y%m%d"`* $DATADIR/BRAA.DAILY1.`date +"%Y%m%d"`

but getting error as -

/data17/cocht/BRAA.DAILY1.20120328*: The system cannot find the path specified.

Is that the directory you're running the script from?

Yes.

i have used -

mget BRAA.DAILY1.`date +"%Y%m%d"`*

and able to download the file.

Thankx,
Rahul

I'm not sure you can specify local filenames like that with mget (haven't used ftp in a while).

Try just changing local directory first using lcd (and not specifying the local names).

Hi,

As i mentioned below, code is working file if i execute the shell script manually but when i added the same script to cron job its not executing.

Plz suggest what could be the cause.

Thankx,
Rahul.