Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to return result to calling app? #3

Open
pauljvallance opened this issue Dec 22, 2018 · 1 comment
Open

How to return result to calling app? #3

pauljvallance opened this issue Dec 22, 2018 · 1 comment

Comments

@pauljvallance
Copy link

you show how to return a result to a dialog box on screen e.g

code,out,err = osascript.run('display dialog "Finished"')

I would like to return a result such as a string of text directly to my calling app ( which is XOJO sending a shell command to Terminal to do script xyz.py. I can get around this by using your osascript.run to call an applescript from within the python script which then sends a custom AppleEvent back to my calling app. it seems that an OSAScript call to run a Python script in MacTerminal returns the id of the Terminal Window.

@andrewpetrochenkov
Copy link
Owner

andrewpetrochenkov commented Dec 22, 2018

if I understand everything correctly, then you need to execute the command in a new Terminal.app window and return the output string?

in that case you need some wrapper. for example, with .command

/tmp/$$.command

#!/usr/bin/env bash

command > /tmp/$$.log
mv /tmp/$$.log ~/app.log

chmod +x /tmp/$$.command
open -a Terminal /tmp/$$.command
while ! [ -e ~/app.log ]; do sleep 1; done
output="$(cat ~/app.log)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants