Posted on 10-28-2020 04:14 AM
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"
Posted on 10-29-2020 06:37 AM
Your FullName var needs to be wrapped as FullName=$(dscl . -read /Users/"$ShortName" RealName | tail -1)