daily pastebin goal
44%
SHARE
TWEET

404-curl-web-error-detecting

tolikpunkoff Mar 21st, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #curl HTTP error detecting
  4. #Using examples:
  5. #./404 ttp://tolik-punkoff.com/net-takoj-stranicy
  6. #CURL error 1
  7. #./404 http://tolik-punkoff.com/net-takoj-stranicy
  8. #HTTP error 404
  9. #./404 http://tolik-punkoff.com/scripts/ip/ip61.php
  10. #OK
  11.  
  12.  
  13. HEADERDUMP="/tmp/headerdump.txt"
  14. SAVEFILE="/tmp/httpfile"
  15. HTTPSTATUS=""
  16.  
  17. curl -o $SAVEFILE $1 -D $HEADERDUMP >/dev/null 2>/dev/null
  18. EXITCODE=$?
  19. if [ $EXITCODE -ne 0 ]; then
  20.     echo "CURL error $EXITCODE"
  21. else
  22.     HTTPSTATUS=`cat $HEADERDUMP|head -1|awk '{print $2}'`
  23.    
  24.     if [ "$HTTPSTATUS" == "200" ];then
  25.     echo "OK"
  26.     else
  27.     echo "HTTP error $HTTPSTATUS"
  28.     fi
  29. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top