| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Spare Parts
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,997
|
htacess? is this possible?
I have been asked to deal with the feed from a digital camera. The camera drops a new file every five minutes into a folder. The client does not want an accumulation of files so wants the files to be deleted once replaced with newer. The files are named including a timestamp and all are unique. Is it possible on the server side to see any new file arriving and rename it to eg camera1.jpg and replace the previous camera1.jpg? Then I can simply set a page refresh rate and continue to ask for the same pic with no issues on the delivery side. Any help apreciated. |
|
|
|
|
|
#2 (permalink) |
|
shiro
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 2,696
|
You could set up a cronjob (if you are on an apache server) to run every five minutes, and check for the presence of any files not named camera1.jpg, and if one exists, rewrite the name to camera1.jpg. You may need to delete camera1.jpg first though - I don't know if renaming the file will allow you to overwrite already existing files, although I assume that it will. You may need to tweak this a little, but you should be able to do it. Functions you can use: blob - to get the names of the files in the directory rename - to rename the file. Use a couple 'if' statements and it should be a fairly basic script! |
|
|
|
#3 (permalink) |
|
Spare Parts
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,997
|
Thanks Haku, I will investigate that. Trouble with my server is it sends an email out everytime a cron job runs. But that could work. I can write the code in a PHP file and just run that every five mins. Yes, yes, thanks. Direct the email to client. Hahahahahhahahaahahahaaahahhha! |
|
|
|
#4 (permalink) |
|
shiro
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 2,696
|
Heh! My server has the email as an option, its not mandatory. Can you not do that? If not, then just point it at a non existent email address. The job should still run, the mail will just go nowhere. |
|
|
|
#8 (permalink) |
|
Everything is fine.
|
Usually CRON mails you if your script outputs anything to STDOUT. I'd double check to make sure it doesn't ECHO anything etc. Otherwise, you should be able to redirect any output to /dev/null and everyything should end up there instead of your inbox; although using this method won't alert you if you script f**ks up for any reason. So use with caution. Edit: You haven't got your email address entered in this box have you "Please enter an email address where the cron output will be sent:"; lol. That would certainly cause it! |
|
![]() |