Change Login Name


A while back I used the script from the thread below to Rename the user account on student computers. Now I am testing out LanSchool and I need use the Login Name of the computer to create classes. The issue is all of the login names are "student", instead of the name students typed in when prompted from the script. Is there a script that will change the login name to match the account name?

[](link URL)

Here is the script I am using.


## Get the logged in user's short name
loggedInUser=$( ls -l /dev/console | awk '{print $3}' )

## Get the logged in user's full name
CurrName=$(dscl . read /Users/${loggedInUser} RealName | awk -F: '{print $NF}' | sed -e 's/^ *//;/^$/d')

getNewName=$(/usr/bin/osascript << EOF
tell application "Finder"
set theName to the text returned of (display dialog "Enter your Full Name below to rename your account" default answer "" buttons {"Enter", "Cancel"} with title "Account Rename")
end tell

theAnswer=$(echo "$getNewName")

## If we got something back for the variable, then the user entered a name. Use it to rename the Student account FullName
if [[ ! -z "$theAnswer" ]]; then
    echo "User entered the full name of ${theAnswer}"
    dscl . change /Users/$loggedInUser RealName "${CurrName}" "$theAnswer"
    ## The variable was blank so they must have cancelled. Exit
    echo "No new name provided"
    exit 0

Contributor III

I know this is a bit old. However, I was hoping to find out how things are going with LanSchool. We have a campus that wants to use it but I have no experience with it.