Skip to main content
Question

Changing users full name via script

  • October 28, 2020
  • 1 reply
  • 0 views

Forum|alt.badge.img+7
  • Valued Contributor
  • 50 replies

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
  • 5 replies
  • October 29, 2020

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings