[Casper] Grep(?) or other method for a logged on user.

DHowell at austinisd.org DHowell at austinisd.org
Thu May 7 13:32:07 PDT 2009


I found this one to work the best for me

username=`/usr/bin/w | grep console | awk '{print $1}'`


than using variable like this /Users/$username/




D. Trey Howell
trey.howell at austinisd.org
Desktop Engineering

This email message, including all attachments, is for the sole use of the 
intended recipient(s) and may contain confidential student and/or employee 
information.  Unauthorized use of disclosure is prohibited under the 
federal Family Education Rights & Privacy Act (20 U.S.C. §1232g, 34 CFR 
Part 99, 19 TAC 247.2, Gov&#8217, t Code 552.023, Educ. Code 21.355, 29 
CFR 1630.14(b)(c)).  If you are not the intended recipient, you may not 
use, disclose, copy or disseminate this information.  Please call the 
sender immediately or reply by email and destroy all copies of the 
original message, including attachments.
 




"Thomas Larkin" <tlarki at kckps.org>
 
Sent by: casper-bounces at list.jamfsoftware.com
05/07/09 02:03 PM

To
"casper at list.jamfsoftware.com" <casper at list.jamfsoftware.com>, "Matt 
Oclassen" <moclassen at salesforce.com>
cc

Subject
Re: [Casper] Grep(?) or other method for a logged on user.






Are these accounts local or part of a directory? 

This could be easily done a few different ways.   First and foremost I 
suggest anyone who manages Macs to keep their local admin accounts hidden, 
in like /private/var for example.  That way it keeps them out of the 
/Users directory.  Then all of your policies in place for your managed 
users can loop through the /users directory.  Since the admin accounts 
won't be there you won't loop them out at all. 

I kind of just came up with a quick way to do this, probably not that 
efficient and someone who is a better script writer may want to try it. 

#!/bin/bash 

#get current user logged in 

current_user=finger -lp | grep Directory | cut -c 19-40 

#now loop through users 

for i in `ls /Users` 

do 

if [[ $i == $current_user ]] 

then jamf policy -trigger MyPolicy 

else echo "not in /Users" 

fi 

exit 
done 

This was written very quick and you may want to write it a better way. 
That is where I would start though.


___________________________
Thomas Larkin
TIS Department
KCKPS USD500
tlarki at kckps.org
blackberry:  913-449-7589
office:  913-627-0351





>>> Matt Oclassen <moclassen at salesforce.com> 05/07/09 1:32 PM >>>
Hello,

I was looking for a command that I could use to verify that a user is 
logged onto their machine before a policy is run (as opposed to a machine 
being on, but sitting at the login screen)

I want to make sure that they are logged in so they are sure to get the 
messaging that this policy has run.

I am imagining something like the following:

If any user is logged in (except for our 2 admin accounts whose name I can 
specify)

Execute  jamf policy –trigger “custom trigger”

Else quit.

Does anyone have an idea on the scripting for this?

Thanks very much,
Matt Oclassen

Desktop Systems Specialist
sales 
force.com


_______________________________________________
Casper mailing list
Casper at list.jamfsoftware.com
http://list.jamfsoftware.com/mailman/listinfo/casper


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.jamfsoftware.com/pipermail/casper/attachments/20090507/3295fba4/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 2778 bytes
Desc: not available
Url : http://list.jamfsoftware.com/pipermail/casper/attachments/20090507/3295fba4/attachment.jpe 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 2788 bytes
Desc: not available
Url : http://list.jamfsoftware.com/pipermail/casper/attachments/20090507/3295fba4/attachment-0001.jpe 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 2834 bytes
Desc: not available
Url : http://list.jamfsoftware.com/pipermail/casper/attachments/20090507/3295fba4/attachment-0002.jpe 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 2861 bytes
Desc: not available
Url : http://list.jamfsoftware.com/pipermail/casper/attachments/20090507/3295fba4/attachment-0003.jpe 


More information about the Casper mailing list