I'm trying to download a file from a URL that looks like this:

http://pdf.example.com/filehandle.ashx?p1=ABC&p2=DEF.pdf

Within the browser, this link prompts me to download a file called x.pdf irrespective of what DEF is (but 'x.pdf' is the right content).

However using wget, I get the following:

>wget.exe http://pdf.example.com/filehandle.ashx?p1=ABC&p2=DEF.pdf
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
--2011-01-06 07:52:05--  http://pdf.example.com/filehandle.ashx?p1=ABC
Resolving pdf.example.com... 99.99.99.99
Connecting to pdf.example.com|99.99.99.99|:80... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2011-01-06 07:52:08 ERROR 500: Internal Server Error.

'p2' is not recognized as an internal or external command,
operable program or batch file.

This is on a Windows Vista system


Edit1

>wget.exe "http://pdf.example.com/filehandle.ashx?p1=ABC&p2=DEF.pdf"
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
--2011-02-06 10:18:31--  http://pdf.example.com/filehandle.ashx?p1=ABC&p2=DEF.pdf
Resolving pdf.example.com... 99.99.99.99
Connecting to pdf.example.com|99.99.99.99|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4568 (4.5K) [image/JPEG]
Saving to: `filehandle.ashx@p1=ABC&p2=DEF.pdf'

100%[======================================>] 4,568       --.-K/s   in 0.1s

2011-02-06 10:18:33 (30.0 KB/s) - `filehandle.ashx@p1=ABC&p2=DEF.pdf'
 saved [4568/4568]
link|improve this question

71% accept rate
feedback

1 Answer

up vote 1 down vote accepted

Put the address in quotes, i.e.:

wget.exe "http://pdf.example.com/filehandle.ashx?p1=ABC&p2=DEF.pdf"

link|improve this answer
Hi @ultrasawblade - please see Edit1 - it didnt download the file properly – matt74tm Feb 6 '11 at 5:11
@matt_tm: You will need to use -O and specify the output filename. – Dennis Williamson Feb 6 '11 at 10:09
@Dennis - it looks like the wrong option - " -o, --output-file=FILE log messages to FILE.". I tried it of course and got the log messages redirected there... – matt74tm Feb 6 '11 at 12:55
@Dennis - its weird, I tried -O (capital "oh") and it didnt work exactly. It downloaded some 5k bytes into an invalid PDF which when I opened it in notepad, showed up as chinese characters on my system. – matt74tm Feb 6 '11 at 13:55
What does the file utility say when you run it on that file? If you load that URL in a browser, do you get a valid PDF? – Dennis Williamson Feb 6 '11 at 15:24
show 3 more comments
feedback

Your Answer

 
or
required, but never shown

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