> On Oct 28, 2014, at 8:00 PM, LuKreme <[email protected]> wrote: > > $USER=$1 > _RUSER=`dscl . -read /Users/$USER RealName | tail -1 > logger -t session "** RUser is \"$_RUSER\"" >
If this is a cut and paste of the script, then the problem is the first line - it should be USER=$1 not $USER=$1. I just tried it out and (with USER=$1) it worked fine for me. This is the script as I used it (slightly different than yours): - - - - - - - - - - #!/bin/sh USER=$1 set > /tmp/hookEnv.txt _RUSER=`/usr/bin/dscl . -read /Users/$USER RealName | tail -1` /usr/bin/logger -t session "** USER is \"$USER\"" /usr/bin/logger -t session "** RUser is \"$_RUSER\”" - - - - - - - - - - I get this when I log out: 10/29/14 12:07:49.756 PM session[3980]: ** USER is "darkshadow" 10/29/14 12:07:49.758 PM session[3981]: ** RUser is "RealName: Michael Nickerson” The environment I get when it runs: - - - - - - - - - - $ cat /tmp/hookEnv.txt BASH=/bin/sh BASH_ARGC=([0]="1") BASH_ARGV=([0]="darkshadow") BASH_LINENO=([0]="0") BASH_SOURCE=([0]="/Library/Hooks/user.sh") BASH_VERSINFO=([0]="3" [1]="2" [2]="53" [3]="1" [4]="release" [5]="x86_64-apple-darwin14") BASH_VERSION='3.2.53(1)-release' DIRSTACK=() EUID=0 GROUPS=() HOSTNAME=StarFire HOSTTYPE=x86_64 IFS=' ' MACHTYPE=x86_64-apple-darwin14 OPTERR=1 OPTIND=1 OSTYPE=darwin14 PATH=/usr/bin:/bin:/usr/sbin:/sbin PIPESTATUS=([0]="0") POSIXLY_CORRECT=y PPID=3975 PS4='+ ' PWD=/ SHELL=/fish/bin/fish SHELLOPTS=braceexpand:hashall:interactive-comments:posix SHLVL=1 TERM=dumb UID=0 USER=darkshadow XPC_FLAGS=0x0 XPC_SERVICE_NAME=com.apple.sessionlogoutd _= - - - - - - - - - - So, it seems to work fine in 10.10. I don’t know if you’d get a launchdaemon working - you can get them running on login by putting them in /Library/LaunchAgents, but I’m not sure how you’d get them to run on logout. There aren’t any settings for that so far as I can see. Maybe if you kept it running and caught when launchd tried to terminate it on log out, but I don’t know if you can do that in a scripting language; I never tried or even thought of it before now. (Man, I haven’t thought of login/logout hooks in forever. Wasn’t I surprised to see that I still had the /Library/Hooks folder I made circa 10.3/10.4 with some old hooks I used to run still present, though the loginwindow plist file didn’t have any reference to them anymore.) —————————————————— Michael Nickerson _______________________________________________ MacOSX-talk mailing list [email protected] http://www.omnigroup.com/mailman/listinfo/macosx-talk
