I have a file "f.txt" present in the following url like below


When I click on the above link in browser, document "f.txt" is downloaded but when I use wget like below

wget XXX-int-wap02/DocApp/doc.asp?Document=YYY

I am able to extract the file but the file is extracted as

File Name : doc.asp?Document=YYY

File Extension : doc.asp?Document=YYY

Then I went through the SU thread here

How to wget a file with correct name when redirected?

Then I modified my wget as below

wget -O f XXX-int-wap02/DocApp/doc.asp?Document=YYY

Using the above the following wget command successfully extracts file as shown below. But the file type is not obtained. See image below.

enter image description here

Prior processing I know what is the actual file name (as such I mentioned it as f in the command ) but I do not know the file extension.

Is there any way I can get the file extraction done with the correct file extension also ?

  • Did you keep reading? The correct answer is in the linked question. – Ignacio Vazquez-Abrams Apr 13 '18 at 4:31
  • I tried wget --trust-server-names and wget --content-disposition and got unrecognized option for both of them :( – UnderDog Apr 13 '18 at 4:37
  • wget --trust-server-names XXX-int-wap02/DocApp/doc.asp?Document=YYY – UnderDog Apr 13 '18 at 4:37
  • wget --content-disposition XXX-int-wap02/DocApp/doc.asp?Document=YYY – UnderDog Apr 13 '18 at 4:37
  • Both of the above commands were not recognized :( – UnderDog Apr 13 '18 at 4:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.