2

I have a function that uses Xfoil to process a data file. However I am trying to tidy up some loose ends. As I am running OS X 10.8.2, Xfoil uses X11 (running as XQuartz) to create its graphs etc. I would like my function to also close the XQuartz app after it has finished so I am trying:

os.system("""'echo osascript -e 'tell application "XQuartz" to quit'""")

but am having no luck. I am using triple double-inverted commas to take the whole thing as a string and os is imported. I believe "osascript -e 'tell application "XQuartz" to quit'" is an Apple Script which I am trying to use with the echo function.

1 Answer 1

4

You are running the wrong command; you are using echo instead of osascript directly, and your single quotes contained in the command are not balanced (you have 3 of them).

It'll be easier to use the subprocess module instead:

import subprocess

subprocess.call(['osascript', '-e', 'tell application "XQuartz" to quit'])

Because subprocess takes a list of process arguments, you don't have to worry (much) about quoting.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.