Operating System - HP-UX
1753344 Members
5108 Online
108792 Solutions
New Discussion юеВ

Re: How to get only todays file from Window 2003 from ftp?

 
SOLVED
Go to solution
diwakar_4
Frequent Advisor

How to get only todays file from Window 2003 from ftp?

Hi All,
Good Morning.

I have to get only current dates csv file from Windows m/c.

1) Script i am using is:

#!/bin/sh
HOST='XXXXXXX'
USER='xxxx'
PASSWD='ppppp'
ftp -n -v $HOST > /usr/mydir/ftp.log << ENDFTP
user $USER $PASSWD
prompt off
binary
cd /wwwroot/
lcd /usr/mydir/
mget *.txt
quit
*******************************
Can some one help me to update the script ?

Thanks

10 REPLIES 10
Mark McDonald_2
Trusted Contributor

Re: How to get only todays file from Window 2003 from ftp?

Might be easier to use a CIFs mount.

OR

Get all the files in to a temp dir (assuming they are not too big) and only copy the ones you want to /ust/mydir. Then remove the temp dir?

There may be a way with ftp but I am not aware of it. Have you looked on google for options to mget?
Mark McDonald_2
Trusted Contributor

Re: How to get only todays file from Window 2003 from ftp?

Also

Could you have a script on the windows machine that renames the files to include the date string?
Steven Schweda
Honored Contributor

Re: How to get only todays file from Window 2003 from ftp?

An easy way would be to have the file (or a
link to the file) placed on the other
(Windows) system in a date-labeled directory,
like, say, "2009-03-04". This would make it
pretty easy to find the desired file (or
files).

Otherwise, I might replace "mget *.txt" in
that script with "dir", save the result, then
look through it for files with the right
date. Finally, create a script which fetches
the desired files.

Looking through FTP directory listings can be
complex, which is one good reason to solve
the problem at the other end.
diwakar_4
Frequent Advisor

Re: How to get only todays file from Window 2003 from ftp?

Many thnaks,

Can i do something like?

1) Let say dir contains todays date files only. I will get all files throgh mget and then move the all the file from current dir to backup dir on windows. Then their wontbe any files left.
Bu can you help me whci command should i use to move the files to other dir.

Thanks
Dennis Handly
Acclaimed Contributor
Solution

Re: How to get only todays file from Window 2003 from ftp?

>can you help me which command should I use to move the files to other dir.

ftp has a del command to remove files. I don't think it has a move command.
If this was HP-UX and both directories were in the same filesystem, you would just hardlink them before and then remove them.
diwakar_4
Frequent Advisor

Re: How to get only todays file from Window 2003 from ftp?

Hi Dennis,

Can we copy files from one dir to other and then delete. FtP servre in windows 2003 server?

Thanks
Dennis Handly
Acclaimed Contributor

Re: How to get only todays file from Window 2003 from ftp?

>Can we copy files from one dir to other and then delete.

Yes, you could copy from windows to HP-UX, then copy back to another folder on windows, then remove original.
Steven Schweda
Honored Contributor

Re: How to get only todays file from Window 2003 from ftp?

> [...] whci command should i use to move the
> files to other dir.

> [...] I don't think it has a move command.
> [...]

"man ftp". Look for "rename". (You know,
like the RENAME command on a user-friendly
OS.) I'd expect most FTP servers to support
it well enough to rename a file to a
different directory, but I'd run the
experiment on the server in question.
OldSchool
Honored Contributor

Re: How to get only todays file from Window 2003 from ftp?

....or you could consider setting up rsync on the windows server to sync up the directories....