Advertisement
Guest User

Untitled

a guest
May 24th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. usage()
  4. {
  5. cat << EOF
  6. usage: random-string
  7.  
  8. This script run the test1 or test2 over a machine.
  9.  
  10. OPTIONS:
  11. -h Show this message
  12. -c Number of characters returned
  13. -s Number of random strings returned
  14. EOF
  15. }
  16.  
  17. characters=32
  18. strings=1
  19.  
  20. while getopts “hc:s:” OPTION
  21. do
  22. case $OPTION in
  23. h)
  24. usage
  25. exit 1
  26. ;;
  27. c)
  28. characters=$OPTARG
  29. ;;
  30. s)
  31. strings=$OPTARG
  32. ;;
  33. esac
  34. done
  35.  
  36. i=1
  37.  
  38. echo ""
  39. echo "Random Strings:"
  40. echo "--------------------------------------"
  41.  
  42. while [[ $i -le $strings ]]
  43. do
  44. LC_CTYPE=C tr -dc A-Za-z0-9_\!\@\#\$\%\^\&\*\(\)-+= < /dev/urandom | head -c $characters | xargs
  45.  
  46. ((i = i + 1))
  47. done
  48.  
  49. echo ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement