Python Forum

Full Version: Create process to control python script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello you all:

I have a question with which approach and resources I have to make the following task:

There is a script in my Ubuntu machine that is called act.py, when act.py runs it performs a few tasks and while performing them, the process has a input() function to wait for operator/user input to continue the task.

My goal is to run a script named main.py that makes processes that executes act.py, when input() raised, the main.py will get notified (which is monitoring whole processes) and let me control the act.py (process) I chose or which raised a flag.

What I tried:

I tried pty.openpty() function which returns me master,slave(fd) but I can't make the terminal take over that fd and interact with it.
fork() will duplicate my master which is really not needed in my opinion.
Using pexpect is easy solution but I can't learn from it where my goal is really study how to get to level where I can control -> take over shells.
Could not really make combination of pty/tty/termios hope someone can clarify what is the best approach addressing this task.
I hope someone can help me with this as I am very enthusiast solving this as it's a big project for my college.

Thank's a lot for helpers.
Is it something that is not allowed?
It is a always a problem when you cross-post without letting people know about it. You waste people's time if they try to help you and suggest things that may have been suggested elsewhere and don't solve your problem/answer your question. The worst is when you find solution elsewhere and people are still trying to help you solve yuor problem. So if you post on multiple sites - let the people know about it.
Above is basically valid for ANY online community
moved to homework as it's a college project/assignment
Yeah I understand, my intentions were to update the post here whenever I find answer.

However, I removed the post there to avoid this behavior.

Thank you for letting me know.