You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Script to force quit all open applications not working get syntax error

If I put the following in Terminal

kill $(osascript -e 'tell app "System Events" to unix id of processes where background only is false'|tr -d ,)

it kills every running process.

 

If I put it in an Apple script, it does not work.  

 

Example:

tell application "Terminal"
            do script "kill $(osascript -e 'tell app "System Events" to unix id of processes where background only is false'|tr -d ,)"
end tell

 

or 

 

do shell script "kill $(osascript -e 'tell app "System Events" to unix id of processes where background only is false'|tr -d ,)"

 

I get an syntax error stating: A identifier can’t go after this “"”.

 

Flagging "System.

 

What do I do wrong?  

MacBook Pro 15″, macOS 10.13

Posted on Jan 17, 2021 2:39 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 17, 2021 1:18 PM

You need to escape the quotes:


do shell script "osascript -e 'tell application \"System Events\" to unix id of processes where background only is false'"



Similar questions

4 replies

Script to force quit all open applications not working get syntax error

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.