Python Forum
Create process to control python script - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Create process to control python script (/thread-27445.html)



Create process to control python script - kobibi11 - Jun-07-2020

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.


RE: Create process to control python script - buran - Jun-07-2020

cross-posted on SO: https://stackoverflow.com/questions/62242214/how-can-we-create-processes-that-can-be-controlled-by-main-with-python


RE: Create process to control python script - kobibi11 - Jun-07-2020

Is it something that is not allowed?


RE: Create process to control python script - buran - Jun-07-2020

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


RE: Create process to control python script - buran - Jun-07-2020

moved to homework as it's a college project/assignment


RE: Create process to control python script - kobibi11 - Jun-07-2020

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.