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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script help please

Status
Not open for further replies.

david6789

Technical User
Nov 9, 2006
5
US
I want to make a simple script that will log onto all 5 servers and do "who" so I can see whos on and be able to "sendnote".

Here is my script:


#!/bin/sh

while read ServerName
do
ssh user@$ServerName "who" > $ServerName.txt
done < inputer.txt


It just hangs there and then when I press enter I get Error:
ssh: connect to host port 22: connection refused


Any ideas?
 
Hi

That script works for me with Bash and MKsh.

What kind of authentication are you using ? If is password based than it is waiting for the password. Better use key based authentication.


Feherke.
 
I am on a solaris system if that helps. The normal login process is: rlogin Alpha

There is no password or usernames; just the server name.

I personally would rather use csh but I am at a lost either way.
 
nope it just sits there, nothing happens. I have to ctrl-c to get out.

What would be an easier shell to use instead of csh?

I want to:
rlogin Alpha
who
rlogin Beta
who
rlogin Charlie
who

And show the results in a file.
 
Hi

First you used [tt]ssh[/tt] and now you are talking about [tt]rlogin[/tt]. So which one are you trying to use ? Or a better question : which one is running ( and accepting connections ) on the remote hosts, [tt]sshd[/tt] or [tt]rlogind[/tt] ?


Feherke.
 
I tried ssh but it did not work (I get port errors) I assume i need to use rlogin.

I tried:

rlogin user@$Alpha

but it requested a password (which we normally do not use)
suggestion?
 
david6789 said:
but it requested a password (which we normally do not use)

Do you mean you normally use rlogin, but it doesn't require a password? Or that you normally do not use rlogin?

rlogin does not understand the username@host syntax, you need to use rlogin hostname -l username... in any case, if you want to use it to run a single command rather than logging in to the remote host you should use rcmd (or remsh on some platforms) isntead.

If rlogin isn't set up at all... then you may as well set up ssh as it is more secure...

Annihilannic.
 
rlogin is the normal way we move from server to server. There is no password involved (except when you first login to the terminal).

I want to see whos on all the servers (all 5 of them).

Usually our scripts are in csh.
 
Does remsh alpha who work? If not, try rsh and/or rcmd instead of remsh.

If any of those work, try something like (using the working command of course):

Code:
#!/bin/sh

while read ServerName
do
    remsh $ServerName "who" > $ServerName.txt
done < inputer.txt

Or alternatively:

Code:
#!/bin/sh

for ServerName in `cat inputer.txt`
do
    remsh $ServerName "who" > $ServerName.txt
done

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top