Operating System - HP-UX
1753731 Members
4609 Online
108799 Solutions
New Discussion юеВ

Re: ftp files one day old

 
poundpooch
Advisor

ftp files one day old

I have written the following to ftp files of only one day old from one server to another eg:
cd /source dir
ftp -n -v -i destination server << EOD
user username password
cd /destination dir
umask 111
find /destination dir -type f -mtime +1 -name "*.dat" -exec mput {} \;

EOD
I keep getting invalid command when I try and run this script anyone any ideas?
9 REPLIES 9
Patrick Wallek
Honored Contributor

Re: ftp files one day old

>>...any ideas?

Yes. You are trying to run a 'find' command from within an FTP Session. I seriously doubt that this will work.

I have not see an FTP program that will allow that.

You will have to figure out some other way to feed your list of files into FTP.
James R. Ferguson
Acclaimed Contributor

Re: ftp files one day old

Hi:

FTP has no idea what to do with 'find...'.

You need to find() the files matching your criteria and pass their names to your script. I would do something like:

MYFILES=$(find /path -type f -mtime +1 -name "*.dat")
{ echo "open myserver
user acctname acctpass
mput ${MYFILES}
close"
} | ftp -i -n -v

Regards!

...JRF...
poundpooch
Advisor

Re: ftp files one day old

Thank you for the fab script it only takes across one file will I have to create a loop?
James R. Ferguson
Acclaimed Contributor

Re: ftp files one day old

Hi (again):

A loop to feed the script I suggested is certainly one way.

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: ftp files one day old

> [...] it only takes across one file [...]

You do realize that we have no idea what your
script actually does in your environment,
right?

> MYFILES=$(find /path [...]

And what did you get in MYFILES?

echo "${MYFILES}"

And we don't really _know_ anything about
what _your_ script is (or does), because
you haven't _showed_ us anything.
poundpooch
Advisor

Re: ftp files one day old

I do realise I havent given any server or actual file details for obvious reasons but you don't need that to answer my query.There is more than one file of the same time stamp that I need to take across so it follows that that the mtime criteria should look to all files and bring across all files of the same time stamp and not just one?
Dennis Handly
Acclaimed Contributor

Re: ftp files one day old

You need to follow the rules for here documents:
$(find /destination-dir -type f -mtime +1 -name "*.dat" -exec echo mput {} +)
EOD

>There is more than one file of the same time stamp

If you do that find outside do you get more than one? -mtime +1 will give all files modified >= 48 hours ago. Unless you used UNIX95=FIDDLE_WITH_FIND_TIMES:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1306285
Suraj K Sankari
Honored Contributor

Re: ftp files one day old

Hi,

Please assign some points who give there valuable time for your problem.

To know how to assign points please go through the below link.


http://forums13.itrc.hp.com/service/forums/helptips.do?#33

Suraj
poundpooch
Advisor

Re: ftp files one day old

thank you all for your help it has been resolved now