Click here to get back home

Finding out the time on an FTP server using perl

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Finding out the time on an FTP server using perl amit.postbox 08-30-2005
Posted by amit.postbox on August 30, 2005, 5:27 am
Please log in for more thread options


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



Posted by Scott W Gifford on August 30, 2005, 10:53 am
Please log in for more thread options


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.


Posted by amit.postbox on August 30, 2005, 12:18 pm
Please log in for more thread options


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



Posted by Mothra on August 30, 2005, 12:27 pm
Please log in for more thread options


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






Posted by Big and Blue on August 31, 2005, 12:30 am
Please log in for more thread options


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 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.


Similar ThreadsPosted
Problems finding gd.pm in perl 5.8.6 using linux February 16, 2006, 4:59 pm
finding the most relevant keywords or phrases of a content using a perl program September 21, 2005, 7:10 am
Using Net::Telnet to connect to Perl server January 22, 2005, 12:57 am
MS SQL server and SQL DATETIME manipulation in perl April 29, 2005, 2:23 am
Net:SSH::Perl oddity when logging in to SSH V2 Server January 16, 2006, 7:03 am
net::ssh::Perl connecting to f-secure ssh server October 10, 2007, 4:07 am
Net::SSH::Perl to connect to a remote server via a web page August 30, 2004, 10:02 am
Microsoft SQL Server 2000 perl module November 11, 2004, 2:12 am
Announce: Win32::SqlServer - access SQL Server from Perl November 27, 2005, 5:03 pm
Finding installed modules January 8, 2008, 4:52 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap