Operating System - HP-UX
1748145 Members
3536 Online
108758 Solutions
New Discussion юеВ

Re: problem in selecting files as per timestamp while ftp

 
hpuserhk
Frequent Advisor

Re: problem in selecting files as per timestamp while ftp

Thanks Steven

I can understand wget is easy way to do this task,but problem is i cant ask client to use 3rd party software ,so i had to resolve this by unix /scripting ,i am trying but getting directory listing first then do some shell script coding to read alternate line match the string and create file of required ftp files,but here again files generated by ftp dir command contain timestamp in DD-MMM-yyyy HHMISS format where
is yesterday date of by unix command is in dd-mm-yyyy format ,so is there any direct command to change format of date or i handle this also by coding

Best Regards
Dennis Handly
Acclaimed Contributor

Re: problem in selecting files as per timestamp while ftp

>files generated by ftp dir command contain timestamp in DD-MMM-yyyy HHMMSS format where as yesterday date of by unix command is in dd-mm-yyyy format

You can't get yesterday's day unless you save it, use perl or a C application.

>is there any direct command to change format of date

date(1) allows you to use any format you like:
date "+%d-%b-%Y"

>I handle this also by coding

Getting "yesterday" may be the toughest.
James R. Ferguson
Acclaimed Contributor

Re: problem in selecting files as per timestamp while ftp

Hi:

We could have been of more help from the beginning had you posted some *actual* samples of your file's data.

As Dennis deduced, this is also a continutation of your earlier "Urgent- Problem in FTP" dated August 27 [where you failed to score the feedback given there]. It would have been clearer to this whole discussion had you continued this there.

Either use 'paste' to join multiple lines of your directory listing as I suggested above, or write a simple shell read loop to join (or not) successive lines based on their content.

All this said, use Perl to compute and format "yesterday's" date.

# DATE=$(perl -MPOSIX -le 'print strftime "%d-%b-%Y",localtime(time-86400)')
# echo $DATE
21-Sep-2008

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: problem in selecting files as per timestamp while ftp

> You can't get yesterday's day unless you
> save it, use perl or a C application.

A programming problem which can be solved
only by using these two languages?
Interesting, but unlikely.

There's already C code in (my) wget to parse
a VMS FTP server listing (which, I claim, is
much easier to do than parsing a UNIX-like
"ls -l" listing), so you can use it, adapt
it, or ignore it and do it all yourself (in
whichever language you find appropriate).
Having already done this work once, I'm not
particularly interested in doing it again,
but you can do what you wish.

> [...] but problem is [...]

Actually, the _big_ problem here is that you
seem to be unable to present a usefully
complete description of the problem you're
trying to solve, and the constraints on the
solution, which pretty much sucks all the fun
out of trying to help you with it.
hpuserhk
Frequent Advisor

Re: problem in selecting files as per timestamp while ftp

Thanks all for your support
Once i free from work i will make necessary assignment for help

I am doing to code it in shell scripting
actually i was avoiding to write more code
and find some way to do it effectively in one command
but this can be handle with shell scripting
by reading and manipulating file containing dir listing
Best Regards