Python Forum
Create process to control python script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create process to control python script
#1
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.
Reply
#2
cross-posted on SO: https://stackoverflow.com/questions/6224...ith-python
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Is it something that is not allowed?
Reply
#4
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
moved to homework as it's a college project/assignment
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Re-write BASH script to Python script popi75 5 2,445 Apr-30-2021, 03:52 PM
Last Post: metulburr
  How to simulate this block diagram with python control library? nugrohoav 1 6,443 May-21-2017, 12:39 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020