I\'m very new to python and applescript. I have a python script which is calling 2 applescripts. I would like to define few global variables in python and pass to applescript 1
os.system()
: Execute the command (a string) in a subshell. This is implemented by calling the Standard C function system(), and has the same limitations.
Changes to sys.stdin, sys.stout
are not reflected in the environment of the executed command.
The return value is the exit status, not the osascript output.
Use subprocess.Popen:
import os, sys, commands
from subprocess import Popen, PIPE
var1 = sys.argv[1]
var2 = sys.argv[2]
(var3, tError) = Popen(['osascript', '/Setup.scpt', var1, var2], stdout=PIPE).communicate()
print var1
print var2
print var3
The osascript
command always returns a string
.
if the AppleScript return a list
, the string in python will be separated by a comma and a space.