开发者

Connect to an existing process

Hole thing is happening on the mac os x.

Let's assume that I've opened an program by clicking on an .app icon. It's a python program with GUI which has a separate process that waits for a user input. But as I've opened it by clickin .app icon I dont have access to it's input as I would have if I ope开发者_C百科ned it in Terminal.

And the question is:

How can I connect new Terminal window to this running program? I tried pipes but I'm not sure how to use them correctly. My guess was to find PID of the app that is running and then pipe to this program by giving a PID. But I have no idea how to do it.

I hope you were able to understand what's the problem. Sorry for my weak english :)


If you need to have a Terminal window connected to your "separate process", I would use the Terminal to launch that process in your python script. I can do that with some applescript code. Here's a simple applescript example. I can open a Terminal window and run the "cd" command like this:

tell application "Terminal"
    activate
    do script with command "cd /"
end tell

So now you just need to figure out how to run an applescript from python... which I don't know.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜