Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm attempting to use wget in a simple bash script to grab a jpeg image from an Axis camera. This script outputs a file named JPEGOUT, instead of the desired output, which should be a timestamp jpeg (ex: 201209292040.jpg) . Changing the variable in the wget statement from JPEGOUT to $JPEGOUT makes wget fail with "wget: missing URL" error.

The weird thing is wget parses the $IP vairable correctly. No luck on the output file name. I've tried single quotes, double quotes, parenthesis: all to no luck.

Here's the script

!/bin/bash

IP=$1

JPEGOUT= date +%Y%m%d%H%M.jpg

wget -O JPEGOUT http://$IP/axis-cgi/jpg/image.cgi?resolution=640x480&compression=25

Any ideas on how to get the output file name to parse correctly?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

JPEGOUT= date +%Y%m%d%H%M.jpg throws an error. Try:

#!/bin/bash

IP=$1

JPEGOUT=$(date +%Y%m%d%H%M.jpg)

wget -O $JPEGOUT http://$IP/axis-cgi/jpg/image.cgi?resolution=640x480&compression=25
share|improve this answer
    
That did it! Thanks! –  Bill Westrup Sep 30 '12 at 2:08

Use command substitution to run the date command and grab the output:

JPEGOUT=`date +%Y%m%d%H%M.jpg`
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.