[Pythonmac-SIG] osascript question
ndrake at polya.net
Sat Oct 4 11:01:32 EDT 2003
I'm new to Python and really new to Applescript. Could someone explain
while the following script works ok from the command-line but not when run
as a CGI?
print "Content-Type: text/html\n\n"
applescript = 'osascript -e \"do shell script \\\"echo This is a shell
the_command = os.popen(applescript)
print "Output of 'do shell script'<p/>"
for line in the_command.readlines():
print("Line: " + line)
print "End of output"
When it is run on the command-line the output of the "osascript" command
is printed in the for loop ok. When run as a CGI only the print
statements right before and right after the for loop print.
Does it have something to do with the fact that do shell script starts a
new sh process?
Is there a way to get something like this to work? In the long run I'm
looking to use osascript and do shell script to get itunes track data in
my python CGI. I tried using PythonIDE's "Generate OSA Suite..." command
on iTunes but I get this:
ASKING FOR aete DICTIONARY IN '/Applications/iTunes.app'
Unpack returned empty value: 
So, that is why I'm not using the Python OSA stuff.
Thanks a lot!
More information about the Pythonmac-SIG