At work we have 5 servers. I would like to write a script that would list all users on the servers (network). So I would not have to log into each servers and type in "who". This will allow me to earily use the "sendnote" function.
Any ideas?
At work we have 5 servers. I would like to write a script that would list all users on the servers (network). So I would not have to log into each servers and type in "who". This will allow me to earily use the "sendnote" function.
Any ideas?
while read serverName
do
ssh user@$serverName "who" > $serverName.txt
done < input.txt
put all server names in the input.txt file
Can you walk me through the script?
like what each word (command) does? Sorry very new to this
while read serverName ---> read the server names (which is present in the input.txt)
do ssh user@$serverName "who" > $serverName.txt --> login to the server using the ssh command and redirect the output of who command to serverName.txt file
done < input.txt --> pass the input.txt
I receive an :
while - Expression syntax
When I try to run it. I created the ServerName.txt and place all the server names in there (1 per line) and the input.txt file (blank)
post your exact code
otherwise, i cant tell where it goes wrong
Ok I created 3 files:
1) inputer.txt (contains the 5 servers names)
2) ServerName.txt (contains nothing "Blank")
3) who.script
my who.script:
# !/bincsh -f
#
while read ServerNAme.txt
do
ssh user@$ServerName "who" > $ServerName.txt
done < inputer.txt
#!/bin/sh
while read ServerName
do
ssh user@$ServerName "who" > $ServerName.txt
done < inputer.txt
---------- Post updated at 09:27 PM ---------- Previous update was at 09:23 PM ----------
replace the user with your login name
ssh user@$ServerName
nice its starting to work:
New Error: ssh: connection to host alpha port 22: Connection refused
The way we normally log on is: rlogin alpha
---------- Post updated at 10:59 AM ---------- Previous update was at 09:00 AM ----------
Any ideas?
David,
through rlogin, i dont know. But alternative is there "ssh"
google it "password less ssh"