Thursday, January 20, 2011

Downloading file with different unique name

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.

  • 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
    • [...]
    : Thanks, exactly what I need.
    freedom_is_chaos : Just realize that unless you throw another option to make like the day or something that it will overwrite the images daily.
  • 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"
    

0 comments:

Post a Comment