Changing users full name via script

jonlju
Contributor

Hi,
I'm working on a script for changing a users full name to be equal to the account name. The script below however gives me an error 53 when running...

#!/bin/bash ShortName=$3 FullName=dscl . -read /Users/$ShortName RealName | tail -1 dscl . -change /Users/$ShortName RealName "$FullName" "$ShortName"

What am I doing wrong here?

Edit: I fixed it now with this script:

#!/bin/bash -x ShortName=$3 FullName=dscl . -read /Users/$ShortName RealName | tail -1 | sed 's/^ *//g' dscl . -change /Users/$ShortName RealName "$FullName" "$ShortName"
1 REPLY 1

scott_gary
New Contributor II

Your FullName var needs to be wrapped as FullName=$(dscl . -read /Users/"$ShortName" RealName | tail -1)