Skip to main content
Question

Changing users full name via script

  • October 28, 2020
  • 1 reply
  • 13 views

Forum|alt.badge.img+7

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

Forum|alt.badge.img+6
  • New Contributor
  • October 29, 2020

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