pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Bash pastebin - collaborative debugging tool View Help


Posted by BossaNesta on Sun 1 Nov 15:37
report abuse | download | new post

  1. # show usage if '-h' or  '--help' is the first argument or no argument is given
  2. case $1 in
  3.         ""|"-h"|"--help") PrSyn ;;
  4. esac
  5.  
  6. # Define all acceptable variable names here
  7. ALL_OPT=(Type Host Pass User DB Table MaxTry BackupDir Src Dst Port sshUser Period dbExtra)
  8. Type="NULL"             # We are using $Type to do syntax check in the call up loop
  9. Period="daily"
  10.  
  11. for WORD in $@ ; do     # $WORD is the name of variable,
  12.   for OPT in ${ALL_OPT[*]} ; do         # Check if I have the option in the list
  13.   FIELDS=""
  14.   case $WORD in
  15.     $OPT=?*)  # To make sure it has '=' and at least one character after '='
  16.       FIELDS=${WORD:`echo ${#OPT}+1 |bc`}       # grap the value
  17.       eval $OPT=$FIELDS                         # Assign the variable to
  18.       echo "      export $OPT $FIELDS"
  19.       ;;
  20.     Report)
  21.       echo "calling up Report"
  22.       bkReport
  23.       break
  24.       ;;
  25.   esac
  26.   [ "$FIELDS" == "" ] || break          # no value at all
  27.   done
  28. done
  29.  
  30. # Display all variable names and value
  31. for OPT in ${ALL_OPT[*]} ; do
  32.     eval aaa=\$$OPT
  33.     echo $OPT = $aaa
  34. done
  35.  
  36. # Define all function names, which is the accepted variables value in first variable in ALL_OPT
  37. ALL_TYPE=(Mysql File MySql Redmine)
  38. [ $Type == "NULL" ] || for TypeCHK in ${ALL_TYPE[*]} ; do
  39.   if [ $Type == $TypeCHK ] ; then
  40.     ChkPeriod $Period
  41.     [ $? == 0 ] && bk$Type #echo -e "\n\n== Running... bk$Type $TypeCHK"
  42.   fi
  43. done

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post