Python Forum

Full Version: Retrieve data from Terminal output or from an ASE variable.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This has something to do with both Python and AppleScript so I wasnt sure where to post it, but since python forums are generally much more active, I decided it would be easier on here.

I have a (WIP) python script which will cal some AppleScripts. To sum up what these do - they open Terminal and run some commands. What I want python to do is retrieve the output of the Terminal. I.E if it says "No such file or directory" in Terminal, I could have an if stament saying that if a variable (error for instance) includes the words "No such file or directory" it would do something. The main thing I want out of this convoluted explanation is python to be able to retrieve the output from terminal without using this for instance,
proc = subprocess.Popen(['echo', 'a', 'b'], stdout=tempf)
, where you have to run a command to get the output.

The other way I thought was to somehow get python to retrieve a variable from the AppleScript. In my AppleScript there is a variable which is called 'output_error' and it is just the entire terminal output. If I could somehow get access that variable from python and take the data, then I could use an if statement in a way to see if the string includes "No such file or directory" or whatever.

Thanks in advance,
Dream