Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an option to wget to force it to write the response even when it's erroneous?

Tags:

bash

soap

wget

I have written a Bash SOAP library that uses wget as the interface to HTTP servers. It's intentional to avoid curl, since that is not available or not installed by default on systems where this library is used.

The basis of the library is the query the WSDL, determine the parameters and allow functions / methods to be invoked from the command line, through a simple wrapper to setup the SOAP urls:

$ ./mysoap.sh MyMethod sKey=1234 bAnotherParameter=False sAnotherParam="Hello"

However, when wget receives a 500 response, it doesn't write the response body to the output document defined by -O. The response contains the SOAP errors that the server generated, which is useful to the client. Is there a way to force wget to write the response to the output document, regardless of the state? The documentation seems to be unclear about the function of -O in the event of an error, so to me, it's not working as intended.

like image 394
Craig Avatar asked May 12 '15 10:05

Craig


People also ask

How do I redirect wget output?

The wget command outputs the document content in a separate file by default. However, we can use the –output-document (-O) option to redirect the content to a file of our choice. As a particular use case, if we use – as the file, it directs the content to stdout.

What can I use instead of wget?

The best alternative is aria2, which is both free and Open Source. Other great apps like Wget are cURL, uGet, ArchiveBox and HTTPie for Terminal. Wget alternatives are mainly Download Managers but may also be Website Downloaders or HTTP Clients.

What is wget spider?

The wget tool is essentially a spider that scrapes / leeches web pages but some web hosts may block these spiders with the robots. txt files. Also, wget will not follow links on web pages that use the rel=nofollow attribute. You can however force wget to ignore the robots.

What is wget log?

Wget is the non-interactive network downloader which is used to download files from the server even when the user has not logged on to the system and it can work in the background without hindering the current process.


1 Answers

This is the option:

Parameter: --content-on-error, available from wget 1.14:

https://superuser.com/a/648466

like image 129
Reto Avatar answered Sep 19 '22 20:09

Reto