hours since file creation

C

cooldaddy

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

Brian McCauley

cooldaddy said:
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.
 
C

cooldaddy

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

A. Sinan Unur

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
 
S

Sherm Pendley

cooldaddy said:
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--
 
B

Brian McCauley

cooldaddy said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top