pmnox
asked on
How can I force wget to save data to file with name that is specified with http header?
How can I force wget to save data to file with name that is specified with http header?
I tried to download file with link
www.server.com/something.cgi@GD=21324
The problem was that wget saved that data to file something.cgi@GD=21324 instead to xlws filename specified in header. How can I fix this?
I tried to download file with link
www.server.com/something.cgi@GD=21324
The problem was that wget saved that data to file something.cgi@GD=21324 instead to xlws filename specified in header. How can I fix this?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you could do it like this if you don't mind doing a short download for just the headers (you need to have the "curl" package installed)
wget -q -O - www.server.com/something.cgi@GD=21324 > `curl -I www.server.com/something.cgi@GD=21324 | grep '^Content-Disposition: ' | sed -r -e 's/^Content-Disposition: attachment;filename=(.*)$/\1/' `
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thx. I have been trying to get it working for a while :]
ASKER
I wanted to do something different. HTTP header specifies correct filename for example:
HTTP/1.1 200 OK
Date: Mon, 25 May 2008 02:13:11 GMT
Server: Apache/1.3.46 (Unix) PHP/4.3.1 mod_perl/1.13 ApacheJserv/1.1.1
Content-Disposition: attachment;filename=MYFILE
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/x-download
I have to download a lot of files and I don't know their filenames before. I want a file to have same name as one specified in Content-Disposition