Avatar of pmnox
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?
SoftwareWindows NetworkingLinux Networking

Avatar of undefined
Last Comment
pmnox

8/22/2022 - Mon
SOLUTION
Net_Worker

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
arulkumarabi

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
pmnox

Hi
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.Xls
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
Rob Siklos

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/' `

Open in new window

ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
pmnox

Thx. I have been trying to get it working for a while :]
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23