20 lines
526 B
Bash
Executable File
20 lines
526 B
Bash
Executable File
#!/bin/bash
|
|
|
|
TEMP=`getopt -o i:P:: --long ip:,port:: \
|
|
-n 'example.bash' -- "$@"`
|
|
|
|
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
|
|
|
# Note the quotes around `$TEMP': they are essential!
|
|
eval set -- "$TEMP"
|
|
|
|
while true ; do
|
|
case "$1" in
|
|
-i|--ip) echo "Option a" ; shift ;;
|
|
-P|--port) echo "Option b, argument \`$2'" ; shift 2 ;;
|
|
*) echo "Internal error!" ; exit 1 ;;
|
|
esac
|
|
done
|
|
echo "Remaining arguments:"
|
|
for arg do echo '--> '"\`$arg'" ; done
|