PDA

View Full Version : Bash SCripting help is needed.


Pizentios
03-08-2002, 03:47 PM
hello,

i have been givin the task at work to write some bash scripts. This is my first time writing one, and yeah well just think of the problems you guys had beack when you learned. Any ways i have been banging my head against my desk over this problem i have read the begginers-guide-to-bash-programming-HOWTO and the Advanced-Bash-Programming-HOWTO and have still not found the answer that i am looking for. Heres the script that i am having trouble with:


#!/bin/bash

until [ -z "$1" ]
do
case "$1" in

-u)
shift
username=$1
;;
-p)
shift
pass=$1
if [ "$pass" = "RAND" ]; then
#TODO: link password generator here
echo i like cheese # this is so it doesn't error out
else
pwd=$pass
fi
;;
-ip)
shift
ip=$1
;;
*)
echo Usage:
echo if you would like createsisuser to generate a random password then type RAND in the password switch.
echo
echo ./createsisuser -u [username] -p [password/RAND] -ip [ip]
exit
;;
esac
done

echo New User Created:
echo
echo
echo Username: $username
echo Password: $pwd
echo Ip: $ip


the script gets run like this: ./createuser -u [username] -p [password/RAND] -ip [ip]

the problem is is when i run it and have all the right switches on the command prompt it still runs the Useage AKA *) or the wild card. is there somthing like a else case?? or is that what the *) is? if it is then why does it keep running the Usage and nothing else?

here is the output i get:

[nick@onramp websis]$ ./createsisuser -u Nick -p foobar -ip 193.87.53.1
Usage:
if you would like createsisuser to generate a random password type RAND in the password switch.

./createsisuser -u [username] -p [password/RAND] -ip [ip]
[nick@onramp websis]$

any idea? i've looked every where i can think of and still have not found what i need...i think...heh

thanks for any help in advance.

Pizentios
03-08-2002, 05:17 PM
you know what...i seem to be on crack or somthing because all it was is there just needed to be another shift at the bottom of the case.

you can now all laugh and point at me...

Dru Lee Parsec
03-08-2002, 05:26 PM
[laughs and points at Pizentios]
AHA!

[Dru then remembers that he himself has been stuck trying to fix the same bug for 8 days now and slinks back into the corner] :(

Pizentios
03-08-2002, 05:49 PM
heh