Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- while getopts "u:p:" opt; do
- case $opt in
- u)
- echo "-u was triggered, Parameter: $OPTARG"
- dbuser="$OPTARG"
- ;;
- p)
- echo "-p was triggered, Parameter: $OPTARG"
- dbpass="$OPTARG"
- ;;
- \?)
- echo "Invalid option: -$OPTARG"
- exit 1
- ;;
- :)
- echo "Option -$OPTARG requires an argument."
- exit 1
- ;;
- esac
- done
- # Clear all options and reset the command line
- shift $(( OPTIND -1 ))
- # First parameter
- if [ -z "$1" ]; then
- echo "usage: $0 [-u name] [-p password] file"
- exit
- fi
Add Comment
Please, Sign In to add comment