Posted on 02-22-2013 08:43 AM
Hey all,
I'm having an issue with what I think is the cause. dscl change command not running correctly in a script triggered at login.
Here is the error return in JSS...
Script exit code: 54
Script result: <main> attribute status: eDSAttributeNotFound
<dscl_cmd> DS Error: -14134 (eDSAttributeNotFound)
Unmounting file server...
And this is my script...
#!/bin/sh
ShortName=`whoami`
FullName=`dscl . -read /Users/$ShortName RealName | tail -1`
FullName2=`echo $FullName | awk '{print}'`
dscl . -change /Users/$ShortName RealName "$FullName2" "$ShortName"
What I'm trying to achieve is to modify the Full Name in "users & groups" to shortname/login name.
Posted on 02-22-2013 09:01 AM
I think the issue is the use of 'whoami' to get the shortname of the logged in user. That is likely pulling the name of your Casper service account since any policy runs under that account.
Casper Suite has a built in variable for the logged in user that works with login policies and Self Service, $3.
Try changing the line
ShortName=`whoami`
to
ShortName=$3
Also, any reason you are echoing back the full name into a new FullName2 variable? I'm not sure if that's necessary, but maybe you ran into some issues without it?
Note that if you plan to use your script with anything other than a login or Self Service trigger, $3 will no longer work. You'd need to use another method to grab the logged in user, like:
ls -l /dev/console | cut -d" " -f4
or
who | awk '/console/{print $1}'
or several other methods that exist.
Posted on 02-22-2013 11:03 AM
The reason for the echo is because the first variable pulls "RealName: jkim".
Here's what happens when I run in terminal.
#!/bin/sh
ShortName=`ls -l /dev/console | cut -d" " -f4`
ls -l /dev/console | cut -d" " -f4
++ ls -l /dev/console
++ cut '-d ' -f4
+ ShortName=jkim
FullName=`dscl . -read /Users/$ShortName RealName | tail -1`
dscl . -read /Users/$ShortName RealName | tail -1
++ dscl . -read /Users/jkim RealName
++ tail -1
+ FullName=' Kim, Johnny'
FullName2=`echo $FullName | awk '{print}'`
echo $FullName | awk '{print}'
++ echo Kim, Johnny
++ awk '{print}'
+ FullName2='Kim, Johnny'
/usr/bin/dscl . -change /Users/$ShortName RealName "$FullName2" "$ShortName"
+ /usr/bin/dscl . -change /Users/jkim RealName 'Kim, Johnny' jkim
And it works on changing the full name to short name! Just not in casper via login trigger.