Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How to download file with different unique name each time

wget -O image.jpg "http://localhost/cgi-bin/nph-zms?mode=single&monitor=1"

Using wget's -O option overwrites file each time. What I want is: image-1.jpg, image-2.jpg, image-3.jpg etc. each time wget is run from cron.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted
wget -O image-`date +%H`.jpg "http://localhost/cgi-bin/nph-zms?mode=single&monitor=1"

If you are doing an hourly check. From looking at the URL you appear to be grabbing it from a webcam.

Your images should be labeled as:

  • image-01
  • image-02
  • [...]
  • image-14
  • image-15
  • [...]
share|improve this answer
    
Thanks, exactly what I need. –  user36299 Feb 28 '10 at 17:43
1  
Just realize that unless you throw another option to make like the day or something that it will overwrite the images daily. –  David Rickman Feb 28 '10 at 18:02
add comment
ser=$(</var/local/image.ser); echo $((++ser)) > /var/local/image.ser; wget -O image-${ser}.jpg "http://localhost/cgi-bin/nph-zms?mode=single&monitor=1"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.