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

Nichols, Jared jared.nichols at ll.mit.edu
Fri May 8 05:47:48 PDT 2009


Perhaps this would be better in this case?

## Set a variable that takes the output of the current console owner and cut the result down
user=`ls -l /dev/console | cut -d " " -f 4`

I haven't tried it, but I would think that if nobody's logged in, /dev/console will be owned by either nobody or root.

j


On 5/7/09 16:50 , "Criss Myers" <cmyers at uclan.ac.uk> wrote:

Hi chaps

Sorry if this doesn't sound right but this us what I do, if have a policy that runs at night time only every 30mins which shutsdown a mac if no one is logged in

For me it was simple, when a user logs in a login hook touchs
/Library/Login/loggedinuser. Then when they logout it removed the file

My policy then checks if that file exists , if so is exits, if not it shutsdown.


To me that seemed the simplist, as I can reuse that log file for abu script, much easier that checking directories and users folders

Criss

On 7 May 2009, at 21:32, DHowell at austinisd.org wrote:


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

<mime-attachment.jpg><mime-attachment.jpg><mime-attachment.jpg><mime-attachment.jpg>

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 <mailto: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 <mailto: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 <mailto:Casper at list.jamfsoftware.com>
http://list.jamfsoftware.com/mailman/listinfo/casper
<http://list.jamfsoftware.com/mailman/listinfo/casper>
_______________________________________________
Casper mailing list
Casper at list.jamfsoftware.com
http://list.jamfsoftware.com/mailman/listinfo/casper


---
Jared F. Nichols
Desktop Engineer, Infrastructure and Operations
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.jamfsoftware.com/pipermail/casper/attachments/20090508/ac43e34c/attachment.htm 


More information about the Casper mailing list