I want to get header response of a URL by using proxy username, password, host and port? is there any Linux command to get the same response?
2 Answers
Something like the following should give you what you want....
export http_proxy="http://myhttpdproxy.com:3128"
wget -q --server-response -O /dev/null --proxy-user=USER \
--proxy-password=PASS http://www.google.co.uk/
(if I have understood the question correctly) Its likely possible to produce some similar result with either curl or perl with LWP module, if you are on a distro with no wget...)

- 11,176
- 5
- 41
- 63
The curl
version of Tom H's answer is:
curl -I -U user:password -x http://myhttpdproxy.com:3128 http://www.google.co.uk/
Both curl
and wget
will also honour environment variables with the username and password such as:
export http_proxy="http://user:password@myhttpdproxy.com:3128"
Feel free to wrap the password in quotes if it contains characters that bash will interpret such as !, *, \, <, >, |, ~
or several others.
Note that using the password on the command line like that will cause it to end up in your bash history and usually be available in a process listing while the command is running. There doesn't seem to be an option to read the password from a file but putting the whole command in a bash script will at least keep the password out of your bash history. Putting the environment variable in your ~/.bash_profile
would seem to be the best method.

- 26,337
- 7
- 59
- 90