Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

too many arguments

Status
Not open for further replies.
Oct 22, 2004
26
Hi chaps As much as I would like to have an argument and kill this machine

Ive now hit a brick wall and really need some help!!


below is my script it doesn't seem to like if [ $display -eq 102 ] I think just I only want gid 102 to be changed and nothing else. If any one can help and point out how stupid i am feel free!!

oh the shell is bin/sh

./pass1.sh: [: too many arguments

echo "Please enter the username that you are wanting to change. Remember that
you must set the password to 123456"
read username
display=`grep $username /etc/passwd | awk -F: '{print $4}'`
if [ $display -eq 102 ]
then
passwd $username
passwd -f $username
else
echo "You don not have access to change this password. Please press ENTER to
exit"
read exit
fi
 
I think maybe your [tt]grep $username /etc/passwd[/tt] is matching more than one line in the password file.

Try chaning that line to...
Code:
display=`grep "^${username}:" /etc/passwd | awk -F: '{print $4}'`
That will make it match from the beginning of the line to a colon.

Hope this helps.
 
Try two things:
1) add a -x after #!/bin/sh so you can see how far the script gets.

2) try putting $display and 102 in qoutes [ "$display" -eq "102" ].
 
Be careful of the syntax of bourne shell scripting. There is a space after the [ and before the ]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top