Hello
I try to make a script to let me know a user who is connected on which machine. The idea is to avoid me having to make all rooms info when I was looking for someone. This is the final script, to call an argument with the person sought. Here machines are called up 01 MACHINE MACHINE 42.
I have several problems./ bin / bash
(function pqui
users = $ (ssh MACHINE-$ 1 users)
result = ""
for user in $ users
do
ssh MACHINE-$ 1 w-s | egrep-q "$ user [[: blank:]] * tty7" & & result = $ result "$ user"
done
if [[! -z $ result]]
then
echo "MACHINE-$ 1: $ result
fi
)
for i in $ (seq-f '% 02g' $ 1 NBPC);
do
pqui $ i &
done
wait
exit 0;
- How to make a single loop from 01 to 42? (for the moment I go from 1 to 9 zeros and then adding 10 to 42)
- How to tell if a user is physically connected? (if I move and there's nobody my script has no interest)
- How do nothing if no one is displayed on the machine?
For the last 2 items I did not find anything by reading the man users. Basically users uses / var / run / utmp, but this file is unreadable. Thank you in advance.
Bookmarks