Re: Test for Multiple Users Logged In
Re: Test for Multiple Users Logged In
- Subject: Re: Test for Multiple Users Logged In
- From: Chris Garaffa <email@hidden>
- Date: Sun, 19 Dec 2004 23:27:47 -0500
On Dec 19, 2004, at 9:53 PM, Matt Neuburg wrote:
Okay, forget what I just said - that won't test whether the other
users are
actually logged in. D'oh!
Try do shell script "w" instead. I think if a user appears as on
terminal p1
or similar, they are not logged in. m.
Out of curiosity, I just played around with this and found that only
the GUI user who logged in first will show up as using TTY 'console.'
The others, as Matt said, will show up as p1, p2, etc. This shell
script will tell you who (other than you) is logged in:
w -h | grep -v `whoami` | awk '{print $1}' | uniq
The only problem I can see is with users who ssh in, if you care about
getting warnings about them. They show up under a p TTY, but are
distinguishable by their entry in the FROM column, where they show up
as the address of the host they are connected from, instead of a dash
(-) as a local user IS.
To get around this, I changed the shell script to:
w -h | grep -v `whoami` | awk '{print $1 " " $3}' | uniq
Then, in AppleScript, you could:
set theUsers to do shell script "w -h | grep -v `whoami` | awk '{print
$1 \" \" $3}' | uniq" -- all users.
set modifiedUsers to {} --this will be a list of users, besides
yourself, who are logged in as local users.
repeat with i from 1 to (count (paragraphs of theUsers))
if last character of paragraph i of theUsers is equal to "-" then
set the end of modifiedUsers to first word of paragraph i of theUsers
end if
end repeat
And now, modifiedUsers is a list of all local, logged in users besides
yourself.
Hope this helps.
--
Chris Garaffa
email@hidden
http://incessant.nilzero.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden