You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

43 lines
612 B

  1. #!/bin/bash
  2. set -e
  3. usage() {
  4. cat <<EOL
  5. USAGE: $(basename $0) url
  6. OPTIONS:
  7. -h, --help
  8. EOL
  9. exit 1
  10. }
  11. main() {
  12. local argc=0
  13. local argv=()
  14. while [ $# -gt 0 ]; do
  15. case $1 in
  16. -h|--help)
  17. usage
  18. ;;
  19. *)
  20. argc=`expr $argc + 1`
  21. argv+=($1)
  22. ;;
  23. esac
  24. shift
  25. done
  26. if [ $argc -lt 1 ]; then
  27. echo "Too few arguments"
  28. exit 1
  29. fi
  30. url=${argv[0]}
  31. http_status_code=`curl -s -w "%{http_code}" -o /dev/null $url`
  32. echo $http_status_code
  33. }
  34. main $*