Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date/Time on script for FTP

Status
Not open for further replies.

nahmed01

IS-IT--Management
Jan 16, 2009
1
US
I using date_suffix="_"$(date +"%m%d%Y") on the script. But the file I am going to FTP are with time. Is there anyway that I can add a logic to grab the file based on the partial name(date)? The files get remote local. But we don no the exact time when the file will be created.
The complete names change daily so you will not be able to specify that. You will have to look for the partial name and then read the full name into a variable or something to do the FTP. The files actually have not only the date but also the time.
What I am doing
echo
“mget $remote_in_file* $local_in_file*
rename $remote_in_file* $remote_out_file”
but the problem is when you ftp its not renaming the file?
Is there anyway I can solve it?
remote_in_file=${REMOTE_FILES[$index]}$date_suffix$ext_suffix


 
It's not very pretty but...

I resolved a similar problem by doing two passes. On the first pass I ran 'ls' under ftp to get a list of the remote files. I redirected this into a file so that I could use this output in a ksh script which then did a second pass to actually get the file.

e.g. (NOT tested in any way - pure for example)
Code:
ftp remote_host << EOF > /tmp/filename.$$
username
password
ls $(remote_in_file}*
bye 
EOF

remote_in_file=$(</tmp/filename.$$)

ftp remote_host << EOF
username
password
get $remote_in_file $local_in_file
rename $remote_in_file $remote_out_file
bye 
EOF

On the internet no one knows you're a dog

Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top