Sponsored Content
Top Forums Shell Programming and Scripting Encapsulating output of CURL and/or WGET Post 302706851 by SkySmart on Thursday 27th of September 2012 01:59:17 PM
Old 09-27-2012
Quote:
Originally Posted by Corona688
How about just letting it print instead of continually cramming everything into backticks? You don't have to always have to do that.

Also, how about checking their return codes instead of grepping their output? Every process you create returns an error code for success or failure, and wget is not an exception. If it fails to download a page, it willl tell you so directly. There's no need to grep for 'error' in the output.

If you're downloading multiple pages and wish to see which succeeded via script, wget has the -nv option, which outputs success or failure for individual files in a simple line-by-line list.

The real problem is, they're not one thing, they're two streams. stdout is used for data, stderr is used for errors.

If you want them both to go to stdout: wget ... 2>&1
thank you for the response.

the task i often have to deal with is, some clients request that a specific URL be curled/wgetted and in the output returned, they want to make sure that there is a certain string(s) contained in it.

so in the previous wget example i gave (its just an example), some clients may want to make sure the words "HTTP request sent, awaiting response" is found in the output. in such a case, just checking for the exit code is not good enough. it helps if, when the check alerts, it also contains the full error message.

lets say the exit code is a non-zero. it would help tremendously to actually be able to see what the failure was.

for instance, after running a wget on a URL, the following was returned:

Code:
<detail><vXMLVersion>0.0.1</vXMLVersion><addressAndMailPieceInformation><vError>Fatal exception during validationjava.lang.NullPointerException</vError></addressAndMailPieceInformation></detail>


Now, this isn't the typical response. So when the URL check was run and got back this error response, it would help if I can actually show the entire message to the output of the GUI. its very difficult putting this response in a variable and outputting it out the way it alerted.

see what i mean?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed in Curl & Wget

We are trying to invoke a https service from our unix script using curl command. The service is not getting invoked because it is SSL configured. Bypassing certification (using curl –k) does not work. curl -k https://site curl -k -x IP:Port https://site curl -k -x IP:443 https://id:pwd@site ... (0 Replies)
Discussion started by: dineshbabu01
0 Replies

2. Shell Programming and Scripting

Proxy with curl/wget support

I need a proxy that would enable me to use cli curl/wget with another ip address. How do I find a paid proxy server that supports curl/wget? (1 Reply)
Discussion started by: locoroco
1 Replies

3. Shell Programming and Scripting

ery weird wget/curl output - what should I do?

Hi, I'm trying to write a script to download RedHat's errata digest. It comes in a txt.gz format, and i can get it easily with firefox. HOWEVER: output is VERY strange when donwloading it in a script. It seems I'm getting a file of the same size - but partially text and partly binary! It... (5 Replies)
Discussion started by: jstilby
5 Replies

4. Shell Programming and Scripting

Specifying IP address with curl/wget

Hello, I am wondering does anyone know of a method using curl/wget or other where by I could specify the IP address of the server I wish to query for a website. Something similar to editing /etc/hosts but that can be done directly from the command line. I have looked through the man pages... (4 Replies)
Discussion started by: colinireland
4 Replies

5. Shell Programming and Scripting

How to download file without curl and wget

Hi I need a Shell script that will download a zip file every second from a http server but i can't use neither curl nor wget. Can anyone will help me go about this task ??? Thanks!! (1 Reply)
Discussion started by: rubber08
1 Replies

6. Shell Programming and Scripting

Wget vs Curl - Proxy issue

Hi, My script needs to crawl the data from a third party site. Currently it is written in wget. The third party site is of shared interface with different IP addresses. My wget works with all the IP address but not with one. Whereas the curl is able to hit that IP address and comes out... (2 Replies)
Discussion started by: sathyaonnuix
2 Replies

7. Shell Programming and Scripting

Wget/curl credentials validation

Experts, I login to a 3rd party and pull some valuable information with my credentials. I pass my credentials via --post-data in wget. Now my Account is locked. I want my wget to alert that the Account is locked. How can i achieve this. My idea is, get the Source page html from the... (2 Replies)
Discussion started by: sathyaonnuix
2 Replies

8. Shell Programming and Scripting

How to get content of a webpage Curl vs Wget?

Hello, What I am trying to do is to get html data of a website automatically. Firstly I decided to do it manually and via terminal I entered below code: $ wget http://www.***.*** -q -O code.html Unfortunately code.html file was empty. When I enter below code it gave Error 303-304 $... (1 Reply)
Discussion started by: baris35
1 Replies

9. Shell Programming and Scripting

Wget and curl to post data

i'm using this command to post data to a remote host: wget --post-data="My Data" http://<my-ip>:80 -O /dev/null -q and curl --data "My Data" http://<my-ip>:80 however, when i run the above, i see the following in my access log on the remote host: Wget: 10.10.10.10 - - "POST /... (1 Reply)
Discussion started by: SkySmart
1 Replies

10. Web Development

Wget/curl and javascript

What can I use instead of wget/curl when I need to log into websites that use javascript? Wget and curl don't handle javascript. (6 Replies)
Discussion started by: locoroco
6 Replies
CURLINFO_SCHEME(3)					     curl_easy_getinfo options						CURLINFO_SCHEME(3)

NAME
CURLINFO_SCHEME - get the URL scheme (sometimes called protocol) used in the connection SYNOPSIS
#include <curl/curl.h> CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SCHEME, char **scheme); DESCRIPTION
Pass a pointer to a char pointer to receive the pointer to a zero-terminated string holding the URL scheme used for the most recent connec- tion done with this CURL handle. The scheme pointer will be NULL or pointing to private memory you MUST NOT free - it gets freed when you call curl_easy_cleanup(3) on the corresponding CURL handle. PROTOCOLS
All EXAMPLE
CURL *curl = curl_easy_init(); if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); res = curl_easy_perform(curl); if(res == CURLE_OK) { char *scheme = NULL; curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme); if(scheme) printf("scheme: %s ", scheme); /* scheme: HTTP */ } curl_easy_cleanup(curl); } AVAILABILITY
Added in 7.52.0 RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. SEE ALSO
CURLINFO_RESPONSE_CODE(3), curl_easy_getinfo(3), curl_easy_setopt(3), libcurl 7.54.0 April 08, 2017 CURLINFO_SCHEME(3)
All times are GMT -4. The time now is 05:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy