Finding out the time on an FTP server using perl

Finding out the time on an FTP server using perl

am 30.08.2005 14:27:13 von amit.postbox

Hello,

Does anybody know how to find out the local time (and the timezone) on
a remote FTP server using perl?

Is there any way to get this info using Net::FTP or any standard CPAN
package?

I've pulled my hair out trying to figure this one but have only
succeeded to get bald in the process.. :(

Cheers
Amit

Re: Finding out the time on an FTP server using perl

am 30.08.2005 16:53:29 von Scott W Gifford

amit.postbox@gmail.com writes:

> Hello,
>
> Does anybody know how to find out the local time (and the timezone) on
> a remote FTP server using perl?

I'm not aware of anything in the FTP protocol that allows that
directly. A few ideas:

* If you control the FTP server, you could also run a time server on
it you could query.

* If you can create a file on the FTP server, you can create it and
immediately ask for the modification time, which will be a good
approximation.

* You could see if there are any other services on the same server
that provide a timestamp, like HTTP.

Also, if you post the problem you're trying to solve, there might be a
way to do it without knowing the current time. For example, if you
want to see if a file has changed since last time you checked, you can
store the modification time of the file, and see if it's newer than
that. If you want to see if a file is still being modified, get the
modification time, sleep for 5 minutes, get it again, and see if it's
changed.

-----Scott.

Re: Finding out the time on an FTP server using perl

am 30.08.2005 17:33:43 von Stephen Patterson

On Tue, 30 Aug 2005 10:53:29 -0400, Scott W Gifford wrote:
> * If you can create a file on the FTP server, you can create it and
> immediately ask for the modification time, which will be a good
> approximation.

Though some kind of checksum may be more useful, especially if you can't get an
accurate mtime. I've found HTTP mtimes rather unreliable at times.

> * You could see if there are any other services on the same server
> that provide a timestamp, like HTTP.
--
Stephen Patterson steve@patter.mine.nu http://patter.mine.nu/ GPG: E3E8E974
Jabber: patter on jabber.earth.li MSN: stephenpatterson893@hotmail.com
"Whoever said nothing is impossible never tried slamming a revolving door."
-- Melissa O'Brien

Re: Finding out the time on an FTP server using perl

am 30.08.2005 21:18:21 von amit.postbox

Hmmm.. tricky.. I pulled out all my hair for nothing :( :( :(

Would there be a way to compute time for another timezone.. eg..
currently our server is following BST (British Standard Time) but the
FTP server would be in New York (DST)... thus would Perl standard CPAN
libraries have something to compute the NY time given BST time? esp
since the daylight savings start at different times of the year at both
places...

Cheers
Amit

Re: Finding out the time on an FTP server using perl

am 30.08.2005 21:27:34 von mothra

amit.postbox@gmail.com wrote:
> Hmmm.. tricky.. I pulled out all my hair for nothing :( :( :(
>
> Would there be a way to compute time for another timezone.. eg..
> currently our server is following BST (British Standard Time) but the
> FTP server would be in New York (DST)... thus would Perl standard CPAN
> libraries have something to compute the NY time given BST time? esp
> since the daylight savings start at different times of the year at
> both places...

You may want to checkout the Perl DateTime project
http://datetime.perl.org/

Hope this helps

Re: Finding out the time on an FTP server using perl

am 31.08.2005 01:30:23 von Big and Blue

Mothra wrote:
>
>>FTP server would be in New York (DST)... thus would Perl standard CPAN
>>libraries have something to compute the NY time given BST time? esp
>>since the daylight savings start at different times of the year at
>>both places...

Doable (on various Unix and Linux systems at least) if you set
$ENV{'TZ'} appropriately between calls to localtime().

On Linux you need a further call to make the TZ stick (POSIX::tzset ??).


--
Just because I've written it doesn't mean that
either you or I have to believe it.

Re: Finding out the time on an FTP server using perl

am 31.08.2005 01:57:06 von Stephen Patterson

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 31 Aug 2005 00:30:23 +0100, Big and Blue wrote:
> Mothra wrote:
>>
>>>FTP server would be in New York (DST)... thus would Perl standard CPAN
>>>libraries have something to compute the NY time given BST time? esp
>>>since the daylight savings start at different times of the year at
>>>both places...

Date::PCalc

- --
Stephen Patterson steve@patter.mine.nu http://patter.mine.nu/ GPG: E3E8E974
Jabber: patter on jabber.earth.li MSN: stephenpatterson893@hotmail.com
"Whoever said nothing is impossible never tried slamming a revolving door."
-- Melissa O'Brien
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDFPJlUKIGN+Po6XQRAvBzAKCs3sTf4Bh3NbJ07gccBD7H+/mKiQCf enOy
cNT/fJYVMiIklvhwwLcAcoU=
=+UUi
-----END PGP SIGNATURE-----

Re: Finding out the time on an FTP server using perl

am 05.09.2005 11:31:46 von chris-usenet

amit.postbox@gmail.com wrote:
> Does anybody know how to find out the local time (and the timezone) on
> a remote FTP server [...]

The perl bit is irrelevant to your question as there is no direct way
of achieving your requirement.

If you have write permission you could try creating a file and then
doing an "ls" on it to see the date/time stamp.

Chris

Re: Finding out the time on an FTP server using perl

am 05.09.2005 13:08:14 von John Bokma

chris-usenet@roaima.co.uk wrote:

> amit.postbox@gmail.com wrote:
>> Does anybody know how to find out the local time (and the timezone) on
>> a remote FTP server [...]
>
> The perl bit is irrelevant to your question as there is no direct way
> of achieving your requirement.
>
> If you have write permission you could try creating a file and then
> doing an "ls" on it to see the date/time stamp.

Response: 220---------- Welcome to Pure-FTPd [TLS] ----------
Response: 220-You are user number 1 of 50 allowed.
Response: 220-Local time is now 11:00. Server port: 21.
Response: 220 You will be disconnected after 15 minutes of inactivity.

Some servers do seem to report a local time.

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html