lost again


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting lost again
# 1  
Old 06-27-2003
shell script

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
# 2  
Old 06-27-2003
Re: shell script

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...
Code:
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

# 3  
Old 06-27-2003
Thanks
# 4  
Old 06-30-2003
lost again

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
# 5  
Old 06-30-2003
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'
# 6  
Old 06-30-2003
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).
# 7  
Old 06-30-2003
Thanks, oombera. I have merged the threads. azman, please reply to this thread if you have further questions about this script.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

I am so lost !!!

I am taking an online Linux class, which is mandatory for me to graduate. Unfortunately I got the worst online teacher ever, he never respond to any e-mails. I have no idea what going on in this class so I am turning to you guys. Here is the questions for the week, Ok I don't expect anybody to... (1 Reply)
Discussion started by: Thunderbunny
1 Replies

2. UNIX for Dummies Questions & Answers

Lost my Way

I want to execute my own utilities from my bin folder without having to specify paths at run time - i.e. just enter name on command line - to do this my search path needs to be set up at login time - when I do this the path is not getting set right apparently(?) - PATH echos OK but the search... (0 Replies)
Discussion started by: robert stansel
0 Replies

3. UNIX for Dummies Questions & Answers

I am so lost...

I have been using linux now for about 6 months. I like it although it was quite a learning process. Pretty simple for the most part. Here is my prob... The first time I installed linux on my computer it went in just fine, no problems. It did eventually crash though and I had to re-install it.... (2 Replies)
Discussion started by: Treb
2 Replies

4. UNIX for Dummies Questions & Answers

I'm so lost...

Fair warning... I know nothing of Unix. That's why I joined this forum and I need your feedback desperatly. Here is the situation... I built an app using ASP and Northcode's SWF Studio v3 for a cd launcher tool for a client that develops software. They like the app and it works well on... (2 Replies)
Discussion started by: daJabberwocky
2 Replies

5. UNIX for Dummies Questions & Answers

ok im like lost and confused!!

:eek: im trying to make a website and im on a site that tells how... but, it says 2 access my unix account to make 1 online and im alrdy confused!! (1 Reply)
Discussion started by: blugsnorfia
1 Replies

6. Filesystems, Disks and Memory

Lost Data Lost Admin

First time so excuse my ignorance please. I may not be accurately describing the issue. I have inherited a small lab mostly SUN V120s. We lost power and are trying to recover. Nope no backups... The primary issue I have is 1 box is an Oracle Server. It has 2 36Gb harddrives. I am able to... (3 Replies)
Discussion started by: murphsr
3 Replies

7. UNIX for Dummies Questions & Answers

So lost

I have been reading up on starting a website, but i am still lost. I am in much need of assistance. Kind of a step by step because i still don't know where to start. please help. thank you (1 Reply)
Discussion started by: sweetie020602
1 Replies

8. Programming

Packets Getting Lost

I am working on a project, which has the following type of hardware setup. A special hardware device is receiving data from an external network interface. So we can have multiple such a hardware devices. Now these hardware devices will route the captured incoming data through the external... (4 Replies)
Discussion started by: S.P.Prasad
4 Replies

9. UNIX for Dummies Questions & Answers

Interested, but lost.

Alright, so I'm interested in using Unix, but I have a couple of pretty basic questions: 1) What's the relationship between Linux and Unix? Are they one and the same, or completely different? 2) Can you use Unix on a laptop? and 3) Where can you get Unix? Thanks for listening. (9 Replies)
Discussion started by: Ned
9 Replies
Login or Register to Ask a Question