Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 17th, 2012  |  syntax: None  |  size: 1.17 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. flag to overwrite download url command
  2. if "$?" -ne "0" then
  3. echo "can't reach the url, n aborting"
  4. exit
  5.        
  6. # put download command here
  7. if (( $? != 0 )) && [[ $1 != -c ]]; then
  8.     echo -e "can't reach the url, n aborting"
  9.     exit
  10. fi
  11. # put stuff to do if continuing here
  12.        
  13. #!/bin/bash
  14. usage () { echo "Here is how to use this program"; }
  15.  
  16. cont=false
  17.  
  18. # g and m require arguments, c and h do not, the initial colon is for silent error handling
  19. options=':cg:hm:' # additional option characters go here
  20. while getopts $options option
  21. do
  22.     case $option in
  23.         c  ) cont=true;;
  24.         g  ) echo "The argument for -g is $OPTARG"; g_option=$OPTARG;; #placeholder example
  25.         h  ) usage; exit;;
  26.         m  ) echo "The argument for -m is $OPTARG"; m_option=$OPTARG;; #placeholder example
  27.         # more option processing can go here
  28.         ? ) echo "Unknown option: -$OPTARG"
  29.         :  ) echo "Missing option argument for -$OPTARG";;
  30.         *  ) echo "Unimplimented option: -$OPTARG";;
  31.     esac
  32. done
  33.  
  34. shift $(($OPTIND - 1))
  35.  
  36. # put download command here
  37. if (( $? != 0 )) && ! $cont; then
  38.     echo -e "can't reach the url, n aborting"
  39.     exit
  40. fi
  41. # put stuff to do if continuing here