连接到现有进程
mac os x 上发生了漏洞。
假设我通过单击 .app 图标打开了一个程序。它是一个带有 GUI 的 python 程序,有一个单独的进程等待用户输入。但是,当我通过单击 .app 图标打开它时,我无法像在终端中打开它一样访问它的输入。
问题是:
如何将新的终端窗口连接到这个正在运行的程序?我尝试过管道,但我不确定如何正确使用它们。我的猜测是找到正在运行的应用程序的 PID,然后通过给出 PID 管道到该程序。但我不知道该怎么做。
我希望您能够理解问题所在。抱歉我的英语很差:)
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 opened 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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要将终端窗口连接到“单独的进程”,我将使用终端在 python 脚本中启动该进程。我可以用一些 applescript 代码来做到这一点。这是一个简单的 applescript 示例。我可以打开一个终端窗口并运行“cd”命令,如下所示:
所以现在你只需要弄清楚如何从 python 运行 applescript...我不知道。
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:
So now you just need to figure out how to run an applescript from python... which I don't know.