Applescript for starting in Safe Boot

I am trying to create a script that will tell Terminal to set the computer to safe boot.

I have:

tell application "Terminal"
do shell script "(sudo nvram boot-args="-x")"
end tell

However the script hangs (when trying to compile) on the third ". What am I doing wrong here? Or is there a better way to script this?

Thanks

Try this:


tell application "Terminal"
do shell script "nvram boot-args='-x'" with administrator privileges
end tell

Hi.

do shell script is for running shell scripts directly from AppleScript. If you’re scripting Terminal to run them, the command’s do script:

tell application "Terminal"
	do script "sudo nvram boot-args='-x'" in window 1
end tell

(I haven’t tested it with this particular shell script code.)

The in parameter’s optional. If it’s omitted, Terminal executes the code in a new window.

Thanks wizboyx86 and Nigel, both work and I learned something.