lost again

will this script work? I want to use it in unix.

clear
ans='y'
While test $ans='y'
do

notfound()
{
echo $response " is not logged in"
}
found()
{
echo $response "is logged into " $name
}
name=`ps -eaf | grep "\<$response\>" | cut -b 80-85`
if
[$name != "<$response\>"];
then
name=`rsh server2 ps -eaf | grep "\<$response\>" | cut -b 80-85`
elif
[$name != "<$response\>"];
then
name=`rsh server3 ps -eaf | grep "\<$response\>" | cut -b 80-85`
elif
[$name != "<$response\>"];
then
name=`rsh server4 ps -eaf | grep "\<$response\>" | cut -b 80-85`
elif
[$name != "\<$response\>"];
then
notfound
else
found
fi
echo " new search? y/n"
read ans
done

Thanks for your help

There's no need to have the subroutines inside the loop and I changed the line with WHILE on it... other than that it looks okay; however I didn't test it so look it over. I'm assuming the value for $response comes from somewhere else...

clear
ans='y'

notfound()
{
 echo $response " is not logged in"
}
found()
{
 echo $response "is logged into " $name
}

while [ $ans == 'y' ]
do
name=`ps -eaf | grep "\<$response\>" | cut -b 80-85`
if [$name != "<$response\>"]
then
 name=`rsh server2 ps -eaf | grep "\<$response\>" | cut -b 80-85`
elif [$name != "<$response\>"]
then
 name=`rsh server3 ps -eaf | grep "\<$response\>" | cut -b 80-85`
elif [$name != "<$response\>"]
then
 name=`rsh server4 ps -eaf | grep "\<$response\>" | cut -b 80-85`
elif [$name != "\<$response\>"]
then
 notfound
else
 found
fi
echo -n "New search? [y/n]: "
read ans
done

Thanks

syntax error at line 72: `end of file ' unexpected Not sure why

#!/bin/sh
clear

found()
{
echo $response " is logged into " $name
}

notfound()
{
echo $response " is not logged in "
}
ans= 'y'
while [ $ans == "y" ]

do
response=
while [ -z "$response" ]
do
echo "Enter User id"
read response
done

name=`ps -eaf | grep "\<$response\>" | cut -b 80-85 `
echo $name

if [ -n "$name" ] ;
then
found
fi

name=`rsh server2 ps -eaf | grep "\<$response\>" | cut -b 80-85`
if [ -n "$name" ] ;
then
found
fi

name=`rsh server3 ps -eaf | grep "\<$response\>" | cut -b 80-85`
if [ -n "$name" ] ;
then
found
fi

name=`rsh servera1 ps -eaf | grep "\<$response\>" | cut -b 80-85`
if [ -n "$name" ] ;
then
found
fi

name=`rsh servera2 ps -eaf | grep "\<$response\>" | cut -b 80-85`
if [ -n "$name" ] ;
then
found
fi

name=`rsh servera3 ps -eaf | grep "\<$response\>" | cut -b 80-85`
if [ -n "$name" ] ;
then
found

if [ -z "name" ] ;
then
notfound
fi

echo -n " New search (y/n) "
read ans

done

You are missing a "fi" in one of your if statements (servera3).

You can't do == with a [ ] style test.

Remove the space from: ans= 'y'

For continuity's sake, this is a continuation of this post. I'm not sure what the error is referring to, since the script you listed only contains 70 lines (including the blank lines).

Thanks, oombera. I have merged the threads. azman, please reply to this thread if you have further questions about this script.

Thanks,

I am new to this, I guess I am just making rookie mistakes.:slight_smile: :smiley: