Question

Given: subprocess.call(['open', file]) literally opens that file in mac os is there such a way as...

Given:

subprocess.call(['open', file]) literally opens that file in mac os

is there such a way as to literally save it withouthaving to manually do it?
(on mac)

this is in python
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Try saving this as "EditOneAndQuit" and then do:

chmod +x EditOneAndQuit
Then start that from Python:

#!/bin/bash
# Start textedit in background
open "$1" &

# Wait till textedit has zero documents open
while true
do
sleep 1
docs=`osascript -e 'tell application "textedit" to get documents'`
if [ -z "$docs" ]; then
# Kill off poor old textedit
osascript -e 'tell application "textedit" to quit'
exit
fi
done
Try it from the shell first, by creating a document and editing it:

ls > fred.txt
./OpenOneAndQuit fred.txt
you should see that the script, along with textedit, exits when you close the document by clicking the red button.

Add a comment
Know the answer?
Add Answer to:
Given: subprocess.call(['open', file]) literally opens that file in mac os is there such a way as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT