Adding keychain entry script errors

CJeffery
New Contributor

I have created a script reading bits on here and man pages but can't get it working.

There are 2 scripts. one is for login keychain the other System.

Both error: Script result: /Library/Application Support/JAMF/tmp/TM Server Auth login: line 3: unexpected EOF while looking for matching `"'<br/>/Library/Application Support/JAMF/tmp/TM Server Auth login: line 6: syntax error: unexpected end of file<br/>

#!/bin/sh

sudo security add-internet-password -l "Time Machine 70” -a "TMUser" -w "********" -D "network password" -r "afp " -s "TimeMachine._afpovertcp._tcp.local./Time Machine Back Up" -T "/System/Library/CoreServices/NetAuthAgent.app/Contents/MacOS/NetAuthSysAgent" -T "/System/Library/CoreServices/NetAuthAgent.app" -T "/System/Library/PrivateFrameworks/SystemAdministration.framework/XPCServices/writeconfig.xpc"

exit
#!/bin/sh
security add-internet-password -l "Time Machine 70” -a "TMUser" -w "*********" -D “Time Machine Password" -r "afp " -s "TimeMachine._afpovertcp._tcp.local./Time Machine Back Up" -T "/System/Library/CoreServices/NetAuthAgent.app/Contents/MacOS/NetAuthSysAgent" -T "/System/Library/CoreServices/NetAuthAgent.app" -T "/System/Library/PrivateFrameworks/SystemAdministration.framework/XPCServices/writeconfig.xpc" /Library/Keychains/system.keychain
exit

If i drop "#!/bin/sh" and "exit" it runs within terminal without any errors and adds the entry exactly as i want.

help... :)

Thanks.

1 REPLY 1

bvrooman
Valued Contributor

You have a few smart quotes in there. TextEdit (and some other apps) replace straight "" characters with “” in an attempt to be helpful, but that can cause issues in scripts.