Guest User

Untitled

a guest
Jan 16th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. getopt --test > /dev/null
  2. if [[ $? -ne 4 ]]; then
  3. echo "getopt --test failed in this environment."
  4. exit 1
  5. fi
  6.  
  7. function quit {
  8. echo "$1"
  9. exit 1
  10. }
  11.  
  12. # Option strings
  13. LONG="producer-dir:,consumer-dir:,username:,password:,url:,kafka-host:,checkpoint-dir:"
  14.  
  15. # read the options
  16. OPTS=$(getopt --longoptions ${LONG} --name "$0" -- "$@")
  17. if [ $? != 0 ]; then
  18. quit "Failed to parse options...exiting."
  19. fi
  20.  
  21. eval set -- "$OPTS"
  22.  
  23. # extract options and their arguments into variables.
  24. while true ; do
  25. case "$1" in
  26. --producer-dir )
  27. PRODUCER_DIR="$2"
  28. shift 2
  29. ;;
  30. --consumer-dir )
  31. CONSUMER_DIR="$2"
  32. shift 2
  33. ;;
  34. --username )
  35. USERNAME="$2"
  36. shift 2
  37. ;;
  38. --password )
  39. PASSWORD="$2"
  40. shift 2
  41. ;;
  42. --url )
  43. URL="$2"
  44. shift 2
  45. ;;
  46. --kafka-host )
  47. KAFKA_HOST="$2"
  48. shift 2
  49. ;;
  50. --checkpoint-dir )
  51. CHECKPOINT_DIR="$2"
  52. shift 2
  53. ;;
  54. -- )
  55. shift
  56. break
  57. ;;
  58. *)
  59. echo "Internal error!"
  60. exit 1
  61. ;;
  62. esac
  63. done
  64.  
  65. `getopt [options] [--] optstring parameters`
Add Comment
Please, Sign In to add comment