wget to download image, link get truncated

2019-08-21 20:37发布

问题:

I have an IP camera and the link below takes a snap shot and show you the picture in your broswer:

http://192.168.5.10:81/snapshot.cgi?user=admin&pwd=888888

I am trying to write a script, using wget to download a snap shot to my local repeatably after a certain period. However, when i use

wget -m -p -k http://192.168.5.10:81/snapshot.cgi?user=admin&pwd=888888

I get the following respond:

 => `192.168.5.10:81/snapshot.cgi?user=admin'
Connecting to 192.168.5.10:81... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Connecting to 192.168.5.10:81... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Authorization failed.

The password part got truncated somehow, that is why i get 401 unauthorized problem. I think it is an easy problem to solve, but I am new to linux, any sugguestions how to fix this?

Thanks in advance

回答1:

You must enclose the URL in double quotes to prevent the ampersand & from being interpreted by the shell. I.e.

wget -m -p -k "http://192.168.5.10:81/snapshot.cgi?user=admin&pwd=888888"