Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > hours since file creation

Reply
Thread Tools

hours since file creation

 
 
cooldaddy
Guest
Posts: n/a
 
      08-20-2005
Im looking for some CGI code to find out how many hours have past since
a file has been created or has been modified. Hope you guys/gals can
help me.

 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      08-20-2005
cooldaddy wrote:
> Im looking for some CGI code to find out how many hours have past since
> a file has been created or has been modified. Hope you guys/gals can
> help me.


What makes you think the mechanism to look at file attibutes would be
different in a CGI environment? (I suspect you may be having difficulty
partitioning your problem).

The Perl -M operator tells you time (in days) from the last modified
time of a file to the start of script execution.

On Unix the -C operator does the same for the inode change time. There's
no concept of creation date in POSIX and if you are using a filesystem
with this concept you'll need filesystem dependant ioctl()s or external
binaries.

I think on Windows with NTFS -C will look at the creation date.

 
Reply With Quote
 
 
 
 
cooldaddy
Guest
Posts: n/a
 
      08-20-2005
Ok, thanks Brian,

So I have to use the -M operator. Can you or someone else give me an
example how to implement this in a cgi script ? I've searched the whole
internet but cant find an cgi example.

 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      08-20-2005
"cooldaddy" <(E-Mail Removed)> wrote in
news:(E-Mail Removed) oups.com:

> Ok, thanks Brian,


[ Please quote appropriately when posting a reply ]

> So I have to use the -M operator. Can you or someone else give me an
> example how to implement this in a cgi script ?


As Brian also asked, what makes you think anything should be different in
a CGI script?

> I've searched the whole internet but cant find an cgi example.


Use the documentation available to you on your computer:

perldoc -f -x

Sinan

--
A. Sinan Unur <(E-Mail Removed)>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html
 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      08-20-2005
"cooldaddy" <(E-Mail Removed)> writes:

> Ok, thanks Brian,


Thanks for what? Please quote enough context for your reply to make sense.

> So I have to use the -M operator. Can you or someone else give me an
> example how to implement this in a cgi script ?


The same way you would in a non-cgi script.

> I've searched the whole internet but cant find an cgi example.


Did you try reading the docs that come with the language you're using?

perldoc -q "file's timestamp"

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      08-20-2005
cooldaddy wrote:

> So I have to use the -M operator. Can you or someone else give me an
> example how to implement this in a cgi script ? I've searched the whole
> internet but cant find an cgi example.


OK, that's a distinctly odd request but since you ask...

use strict;
use warnings;

print "Content-type: text/plain\n\n";

print "The file foo is ",( -M 'foo' )," days old";
__END__

And just how were you expecting that to help?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Excel time-format (hours since 1.1.1901) Dirk Hagemann Python 18 12-10-2007 07:10 PM
Recorded 2 hours, deleted 2 hours, no space left? Tony Tee DVD Video 5 07-25-2007 10:20 AM
1700 series: S0 is up 2 hours, down 2 hours, up, down, arghgh! Ivan Cisco 11 10-14-2004 08:41 AM
Seconds/Hours/Days etc.. since user last visited tdi1686 ASP .Net 2 08-13-2003 12:32 PM
Hi im going to make a "time counter" from hours to hours and a loggfile export system Rahmi Acar C++ 0 07-17-2003 08:28 PM



Advertisments