![]() |
execute commands inside a running application - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: execute commands inside a running application (/thread-36911.html) |
execute commands inside a running application - mr_byte31 - Apr-11-2022 I have an application that execute AT commands on certain device via USB. First I have to open Terminal, run the application via command line then start to execute AT commands. I tried to write some script with python using subporcess module but it didn't workmy first trial import subprocess p1 = subprocess.run(['connectDev'], capture_output=True, text=True) #print(p1.stdout) p2 = subprocess.run(['AT+XYZ'], capture_output=True, text=True) print(p2.stdout)the script was waiting for the application to finish but it keep waiting. I also tried : import subprocess results = subprocess.Popen(['connectDev'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) results.poll() stdout,stderr = results.communicate() print(stdout)is there anyway that I can run the AT commands using Python after I exeucte the application(connectDev) ? RE: execute commands inside a running application - Larz60+ - Apr-11-2022 see: https://python-forum.io/thread-35651-post-150540.html#pid150540 RE: execute commands inside a running application - mr_byte31 - Apr-12-2022 (Apr-11-2022, 08:39 PM)Larz60+ Wrote: see: https://python-forum.io/thread-35651-post-150540.html#pid150540Thx anyway. I already saw it before I wrote the thread. the post you send, connects the device via ttyUSB but mine requires an application to connect. the application is doing a lot of things rather than connecting to USB since there there some protection added to connect to this device. RE: execute commands inside a running application - Larz60+ - Apr-12-2022 my_byte31 Wrote:the post you send, connects the device via ttyUSB but mine requires an application to connect. The thread shown shows an application that connects, reads and writes AT commands. You can add whatever you wish in addition to that. I guess I don't understand exactly what you are looking for. Using a subprocess executes the commands outside of the application. |