Skip to main content
added 16 characters in body
Source Link
meuh
  • 54.8k
  • 2
  • 70
  • 140

You need to distinguish between errors that curl sees, and errors that your http server is returning. The latter are not errors for curl. You can however easily inspect the http status code by adding to your curl the option

 -w '%'\n%{http_code}\n' 

This will append to stdout the HTTP header, which is 200 for OK. So your perl can do something like

my $curl_result = `curl -s -S -w '%'\n%{http_code}\n' ...`; 2>/dev/null`; my @lines = split(/\n/,$curl_result); my $httpcode = $lines[-1]; if($httpcode eq 200){ print "ok\n"; } else{ print "error\n"; } 

You need to distinguish between errors that curl sees, and errors that your http server is returning. The latter are not errors for curl. You can however easily inspect the http status code by adding to your curl the option

 -w '%{http_code}\n' 

This will append to stdout the HTTP header, which is 200 for OK. So your perl can do something like

my $curl_result = `curl -s -S -w '%{http_code}\n' ...`; my @lines = split(/\n/,$curl_result); my $httpcode = $lines[-1]; if($httpcode eq 200){ print "ok\n"; } else{ print "error\n"; } 

You need to distinguish between errors that curl sees, and errors that your http server is returning. The latter are not errors for curl. You can however easily inspect the http status code by adding to your curl the option

 -w '\n%{http_code}\n' 

This will append to stdout the HTTP header, which is 200 for OK. So your perl can do something like

my $curl_result = `curl -s -S -w '\n%{http_code}\n' ... 2>/dev/null`; my @lines = split(/\n/,$curl_result); my $httpcode = $lines[-1]; if($httpcode eq 200){ print "ok\n"; } else{ print "error\n"; } 
Rollback to Revision 1
Source Link
meuh
  • 54.8k
  • 2
  • 70
  • 140

You need to distinguish between errors that curl sees, and errors that your http server is returning. The latter are not errors for curl. You can however easily inspect the http status code by adding to your curl the option

 -w '\n%'%{http_code}\n' 

This will append to stdout the HTTP header, which is 200 for OK. So your perl can do something like

my $curl_result = `curl -s -S -w '%{http_code}\n' ...`; my @lines = split(/\n/,$curl_result); my $httpcode = $lines[-1]; if($httpcode eq 200){ print "ok\n"; } else{ print "error\n"; } 

You need to distinguish between errors that curl sees, and errors that your http server is returning. The latter are not errors for curl. You can however easily inspect the http status code by adding to your curl the option

 -w '\n%{http_code}\n' 

This will append to stdout the HTTP header, which is 200 for OK. So your perl can do something like

my $curl_result = `curl -s -S -w '%{http_code}\n' ...`; my @lines = split(/\n/,$curl_result); my $httpcode = $lines[-1]; if($httpcode eq 200){ print "ok\n"; } else{ print "error\n"; } 

You need to distinguish between errors that curl sees, and errors that your http server is returning. The latter are not errors for curl. You can however easily inspect the http status code by adding to your curl the option

 -w '%{http_code}\n' 

This will append to stdout the HTTP header, which is 200 for OK. So your perl can do something like

my $curl_result = `curl -s -S -w '%{http_code}\n' ...`; my @lines = split(/\n/,$curl_result); my $httpcode = $lines[-1]; if($httpcode eq 200){ print "ok\n"; } else{ print "error\n"; } 
added 2 characters in body
Source Link
meuh
  • 54.8k
  • 2
  • 70
  • 140

You need to distinguish between errors that curl sees, and errors that your http server is returning. The latter are not errors for curl. You can however easily inspect the http status code by adding to your curl the option

 -w '%'\n%{http_code}\n' 

This will append to stdout the HTTP header, which is 200 for OK. So your perl can do something like

my $curl_result = `curl -s -S -w '%{http_code}\n' ...`; my @lines = split(/\n/,$curl_result); my $httpcode = $lines[-1]; if($httpcode eq 200){ print "ok\n"; } else{ print "error\n"; } 

You need to distinguish between errors that curl sees, and errors that your http server is returning. The latter are not errors for curl. You can however easily inspect the http status code by adding to your curl the option

 -w '%{http_code}\n' 

This will append to stdout the HTTP header, which is 200 for OK. So your perl can do something like

my $curl_result = `curl -s -S -w '%{http_code}\n' ...`; my @lines = split(/\n/,$curl_result); my $httpcode = $lines[-1]; if($httpcode eq 200){ print "ok\n"; } else{ print "error\n"; } 

You need to distinguish between errors that curl sees, and errors that your http server is returning. The latter are not errors for curl. You can however easily inspect the http status code by adding to your curl the option

 -w '\n%{http_code}\n' 

This will append to stdout the HTTP header, which is 200 for OK. So your perl can do something like

my $curl_result = `curl -s -S -w '%{http_code}\n' ...`; my @lines = split(/\n/,$curl_result); my $httpcode = $lines[-1]; if($httpcode eq 200){ print "ok\n"; } else{ print "error\n"; } 
Source Link
meuh
  • 54.8k
  • 2
  • 70
  • 140
Loading