For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > August 2005 > unknown error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author unknown error
James

2005-08-26, 3:56 am

for uid in `$AWK -F":" '{print $3}' $PASSWD` ; do
user=`grep "${uid}" $PASSWD | $AWK -F ":" {'print $1'}`
password=`grep "${user}" $SHADOW | $AWK -F ":" {'print $2'}

# line 37
if [ $password = "!!" ] ; then
#code

#line 42
elif [ $password = "*" ] ; then
#code

and I get the following errors could someone tell me where I am going wrong.

../script: line 37: [: too many arguments
../script: line 42: [: too many arguments


Måns Rullgård

2005-08-26, 3:56 am

"James" <invaild> writes:

> for uid in `$AWK -F":" '{print $3}' $PASSWD` ; do
> user=`grep "${uid}" $PASSWD | $AWK -F ":" {'print $1'}`
> password=`grep "${user}" $SHADOW | $AWK -F ":" {'print $2'}
>
> # line 37
> if [ $password = "!!" ] ; then
> #code
>
> #line 42
> elif [ $password = "*" ] ; then
> #code
>
> and I get the following errors could someone tell me where I am going wrong.
>
> ./script: line 37: [: too many arguments
> ./script: line 42: [: too many arguments


$password probably contains spaces. Try putting quotes around it.

--
Måns Rullgård
mru@inprovide.com
Rainer Temme

2005-08-26, 3:56 am

James wrote:
....
> # line 37
> if [ $password = "!!" ] ; then
> #code
>
> #line 42
> elif [ $password = "*" ] ; then
> #code
>
> and I get the following errors could someone tell me where I am going wrong.
>
> ./script: line 37: [: too many arguments
> ./script: line 42: [: too many arguments

....

Hi James,

-> "set -x" is youtr friend when it comes to strange
things in shell-scripts.

Try

if [ "$password" = "!!" ] ; then
....
elif [ "$password" = "*" ] ; then
....

and remember that * as well as !! are "special characters" that
means they get interpreted (and replaced) by the shell.

Regards ... Rainer
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com