UPDATE: The latest version of the Foscam firmware, 11.25.2.44, allows you to name the file that is being uploaded to FTP. This process is no longer needed at that point, just upload to your web server directly.
In the second installment here of my simple bat file series, I wanted to give a small instructable on how I set up "Grandpa's Denver weather page" using existing functionality of the Foscam IP camera and a simple bat file. When looking at this I understand that some may perceive it as more of a convoluted process than a simple one, but here goes.
My retired father enjoys watching the weather. Living in Iowa, their weather can be vastly different than ours in Denver. When Foscam had a IP camera sale going on, I snagged one of their outdoor night vision cameras with the thought that I'd use it to watch wildlife attack our garden at night and to update a low bandwidth camera page where my father could see our backyard and weather.
The first thing I did was have the Foscam FI8904 upload an image to a local FTP server every 5 minutes via the options in its built-in web server, which you can see in the picture below. I chose to upload it to a local FTP server as I wanted to be able to manipulate the files locally, before sending them up to my hosting account.
Once on the local FTP server, I simply run a simple bat file via Scheduled Task on my low power home server, also every 5 min, to parse the directory, rename the picture, and upload it to my hosting account. It should be noted that my hosting provider does not accept PASV FTP, so I had to download WinSCP to use in the bat file vs. using the inherent Windows FTP program, your mileage may vary.
Code:
set home=\\diskstation\web\kickassmeals15\foscam\ if exist C:\admintools\gardencamupdate\filelist.txt del C:\admintools\gardencamupdate\filelist.txt dir /b \\diskstation\web\kickassmeals15\foscam\*.jpg > C:\admintools\gardencamupdate\filelist.txt @for /f "tokens=1" %%a in (C:\admintools\gardencamupdate\filelist.txt) do if %%a NEQ gardenweather.jpg copy /Y %home%%%a %home%gardenweather.jpg & if %%a NEQ gardenweather.jpg del %home%%%a del C:\admintools\gardencamupdate\filelist.txt REM Next, let's do the FTP upload pushd %home% "C:\Program Files\WinSCP\winscp.com" /script=C:\admintools\gardencamupdate\ftp.txt
Once you have the new image uploaded to your hosting provider (with the simple bat file), now all you do is simply reference it in the web page and force the page to refresh every 5 min.
HTML Code:
<head> <meta http-equiv="refresh" content="600"> <title>Grandpa's Denver Weather Page</title> </head> <center> <p><a href="http://www.findlocalweather.com/forecast/co/denver.html" target="_blank"><img src="http://www.findlocalweather.net/forecast.php?forecast=hourly&pands=denver+co&config=png&alt=hwicbb" border="0" alt="Click for the latest Denver weather forecast."></a></p> <p><img src="gardenweather.jpg" name="webcam" onload="InitialImage()" width="640" height="480"></p> <p><iframe src="http://free.timeanddate.com/clock/i2un5wme/n75/fcfff/tc009/bo2/tt0/tm1/ta1/tb4" frameborder="0" width="173" height="36"></iframe></p> <P><FONT FACE="Monotype Corsiva"><a href="http://www.gayerfamilyrecipes.com">Back to Grandma's recipe site</a></font></p>
vBulletin Message