Warning: Declaration of PageLinesHighlight::section_template($clone_id) should be compatible with PageLinesSection::section_template() in /var/www/marcusnyberg.com/wp-content/themes/pagelines/sections/highlight/section.php on line 0

Warning: Declaration of PLheroUnit::section_template($clone_id) should be compatible with PageLinesSection::section_template() in /var/www/marcusnyberg.com/wp-content/themes/pagelines/sections/hero/section.php on line 0

Warning: Declaration of PageLinesBanners::section_template($clone_id) should be compatible with PageLinesSection::section_template() in /var/www/marcusnyberg.com/wp-content/themes/pagelines/sections/banners/section.php on line 0

Warning: Declaration of PageLinesCarousel::section_template($clone_id) should be compatible with PageLinesSection::section_template() in /var/www/marcusnyberg.com/wp-content/themes/pagelines/sections/carousel/section.php on line 0

Warning: Declaration of PLMasthead::section_template($clone_id) should be compatible with PageLinesSection::section_template() in /var/www/marcusnyberg.com/wp-content/themes/pagelines/sections/masthead/section.php on line 0

Warning: Declaration of PLNavBar::section_template($clone_id, $location = '') should be compatible with PageLinesSection::section_template() in /var/www/marcusnyberg.com/wp-content/themes/pagelines/sections/navbar/section.php on line 0

Warning: Declaration of PageLinesQuickSlider::section_template($clone_id) should be compatible with PageLinesSection::section_template() in /var/www/marcusnyberg.com/wp-content/themes/pagelines/sections/quickslider/section.php on line 0

Warning: Declaration of PageLinesQuickSlider::section_head($clone_id) should be compatible with PageLinesSection::section_head() in /var/www/marcusnyberg.com/wp-content/themes/pagelines/sections/quickslider/section.php on line 0

Warning: Declaration of PageLinesFeatures::section_template($clone_id) should be compatible with PageLinesSection::section_template() in /var/www/marcusnyberg.com/wp-content/themes/pagelines/sections/features/section.php on line 0

Warning: Declaration of PageLinesFeatures::section_head($clone_id) should be compatible with PageLinesSection::section_head() in /var/www/marcusnyberg.com/wp-content/themes/pagelines/sections/features/section.php on line 0
Marcus Nyberg | Script to handle webcam ftp uploads on a web server

I bought this really cheap webcam from DealExtreme. That camera is now providing one of my websites with live images. The cameras internal webserver can’t handle that many request, so I am using the ftp-feature to upload images to my web server.

webcam

One problem is that each photo’s filename consists of a timestamp, like ”20130404_1223.jpg”. Instead I want the filename to be something like ”webcam.jpg”. Another problem is that the ftp feature fill my webserver with too many photos, so I need to purge the upload directory.

I wrote this script that purges the upload directory from ALL but THE LATEST photo. It also renames the remaining photo to webcam.jpg as I wanted.

#!/usr/local/bin/bash
cd /path/to/webcamftp
(ls -rt *.jpg|tail -n 1;ls *.jpg)|sort|uniq -u|xargs rm
ls *.jpg | xargs -I '{}' mv '{}' webcam.jpg
Share →

Kommentera

E-postadressen publiceras inte. Obligatoriska fält är märkta *