Getting back to
my post on displaying the file creation date and time, a couple of readers have sent in helpful suggestions. Before I get to one, let me briefly recap what I am trying to do.
Via a security webcam/server at home, I periodically ftp an image to my website, seto.org. A web page I’ve created then displays the image. Every once in awhile, I check the web page to see what’s going on at home. But want I wanted was a way of time stamping the image so I would know when it was taken. I found that a Linux program called Stamp! would do that. Sort of. What Stamp! does is uses the current system time and overlays the image with that. This causes a problem for me in that Stamp! may be updating even if the webcam is turned off. This means the image that is sitting on seto.org could be several hours old, but by just viewing the web page, you would have very little, if any way of knowing this.
So I searched for a program that would overlay the test.jpg file with the file’s creation date and time. I have been unsuccessful in finding such a program. So, I tried finding some Perl script that would at least read the creation date and time of test.jpg and then insert/output the result into the web page that also displays the image.
By searching the web, I found a code snippet that supposedly reads the file date and time but ran into problems. Which is where we left off.
A reader by the name of Peter, sorry I don’t have is last name so I can’t give him full credit but he knows who he is, suggested the following:
#!/usr/bin/perl use File::stat; use Time::localtime; $file='/path/to/test.jpg'; $date_string = ctime(stat($file)->mtime); print "file $file updated at $date_string\n";
Making this executable and running this from the command line displays the wanted date and time of the file. Now I could use some help in figuring out how to display this information in a web page that also displays the test.jpg file so that, using a web browser, I can see the test.jpg image and the date and time of the test.jpg file (If this information can be overlayed on the test.jpg itself like Stamp! does would be a bonus but I don’t know of any programs that will do that. So, just displaying the date and time of the file in HTML would be better than what I have now.).
The present web page code itself is below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Seto.org Upstairs</title> <meta http-equiv="refresh" content="60"> </head> <body> <img src="/path/to/test.jpg" width="640" height="480" alt=" Upstairs Web Cam."> <p>Refreshes automatically every 60 seconds.</p> </body> </html>
A big thank you to Peter and to fellow Daynoter John Dominik who suggested a different way of doing it.
UPDATE: Go here for one way of solving the problem.