Intermittent "Syntax Error" when trying to deploy known good scripts

MD56
New Contributor

Hi everyone,

JSS 8.1

very frustrating problem. For a while now we've been dealing with the following error when trying to deploy scripts via casper remote. I understand this is a common issue, but we seem to be having uncommon results to the fix.

So here is the script i am attempting to deploy. We have a bunch of Conference rooms systems that were setup to Auto-login and we want to remove that.

#!/bin/sh

defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser
 rm /etc/kcpassword

exit

I've tested the syntax and believe that it is working. However, when I try to deploy this, or any other script that I've created recently I return the following error

Authenticating... Successfully authenticated. Verifying Computer's Identity... The MAC Address has been verified. Checking Operating System Version... Running Mac OS X 10.7.4 (11E53) Verifying /usr/sbin/jamf... /usr/sbin/jamf is current (8.1) Verifying /usr/sbin/jamfvnc... /usr/sbin/jamfvnc is current (8.1) Verifying /Library/Preferences/com.jamfsoftware.jamf.plist... Preparing Policy... Downloading nomoautologon.sh... Running Script nomoautologon.sh... Script Exit Code:2 Script Result: /private/tmp/nomoautologon.sh: line 1: syntax error near unexpected token `newline' /private/tmp/nomoautologon.sh: line 1: `'

I've read up on this previously and it appears that recreating the symlink is the fix, however i've done this several time and it does not seem to have any effect. Any advice would be appreciated!

4 REPLIES 4

calum_carey
Contributor

line endings?
try creating the script with pico/nano or bbedit/text wrangler?

cvgs
Contributor II

Try to download the script directly from your distribution point and verify if get the correct script or only an HTML page containing an error message. Casper is not able to detect this and just tries to run that error page as a script (which will fail, of course).

acdesigntech
Contributor II

Yes, can you run the script locally on the Mac (not from Casper?). copy the file to the desktop, make it executable (or right-click it and open with Terminal). Does it run or error out?

I try to only ever write scripts in Textwrangler or pico/nano. Also be extra careful if you copy/paste from a website, since the HTML and/or font formatting can wreak havoc on the script.

mm2270
Legendary Contributor III

Agreed. When you see the error near unexpected token `newline` it usually means formatting in the script file that doesn't belong there and messes it up.

Like @acdesigntech, I write almost all my scripts in TextWrangler. Its free and does a great job of making sure the formatting is correct for scripts, and it has several other very useful features.