try changing the interpreter from sh to bash.
try changing the interpreter from sh to bash.
forgive me I'm new to Jamf, where would I do that?
forgive me I'm new to Jamf, where would I do that?
change the #!/bin/sh to #!/bin/bash
forgive me I'm new to Jamf, where would I do that?
All is well. This is a script thing not a Jamf thing. The first line of a macOS script or any Unix script is called the shebang, that is where you specify the interpreter the script will use. Change that first line from #!/bin/sh to #!/bin/bash. You are currently using the sh interpreter; ideally you want to use bash or zsh and occasionally python3 with some osascript (Apple Script) from time to time. The shebang determines what "language" the script needs to be written in, and a script that works with one shebang will not necessarily work with another.
Try the code this way instead.
#!/bin/bash
# determines current user
consoleUser=$( /usr/bin/stat -f%Su /dev/console )
if b$consoleUser == "student"]; then
dscl . create /Users/$consoleUser Picture "/Users/Shared/THS_Files/images/Howie.png"
fi
if b$consoleUser == "howardstudent"]; then
dscl . create /Users/$consoleUser Picture "/Users/Shared/THS_Files/images/Howie.png"
fi
All is well. This is a script thing not a Jamf thing. The first line of a macOS script or any Unix script is called the shebang, that is where you specify the interpreter the script will use. Change that first line from #!/bin/sh to #!/bin/bash. You are currently using the sh interpreter; ideally you want to use bash or zsh and occasionally python3 with some osascript (Apple Script) from time to time. The shebang determines what "language" the script needs to be written in, and a script that works with one shebang will not necessarily work with another.
Try the code this way instead.
#!/bin/bash
# determines current user
consoleUser=$( /usr/bin/stat -f%Su /dev/console )
if [$consoleUser == "student"]; then
dscl . create /Users/$consoleUser Picture "/Users/Shared/THS_Files/images/Howie.png"
fi
if [$consoleUser == "howardstudent"]; then
dscl . create /Users/$consoleUser Picture "/Users/Shared/THS_Files/images/Howie.png"
fi
Thanks but I still got the error.
Thanks but I still got the error.
@TonyNelson At a minimum you need a space after the [ and before the ] in your if statements. You should also take a look at https://www.shellcheck.net/ as a way to check for common errors in a shell script.
@TonyNelson At a minimum you need a space after the and before the ] in your if statements. You should also take a look at https://www.shellcheck.net/ as a way to check for common errors in a shell script.
wow, shell check sure is neat. may install that locally, thanks for posting that.
after editing the script in shell check, this one seemed to work.
#!/bin/bash
# determines current user
consoleUser=$( /usr/bin/stat -f%Su /dev/console )
if r "$consoleUser" == "student" ]; then
dscl . create /Users/"$consoleUser" Picture "/Users/Shared/THS_Files/images/Howie.png"
fi
if r "$consoleUser" == "howardstudent" ]; then
dscl . create /Users/"$consoleUser" Picture "/Users/Shared/THS_Files/images/Howie.png"
fi
@TonyNelson At a minimum you need a space after the [ and before the ] in your if statements. You should also take a look at https://www.shellcheck.net/ as a way to check for common errors in a shell script.
Thanks, and Plus one about shellCheck. However I must be missing something as the script ran with no errors but the profile picutre still didn't change.