Subprocess command working for one cmd and for cmd one not wrking - 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: Subprocess command working for one cmd and for cmd one not wrking (/thread-25276.html) |
Subprocess command working for one cmd and for cmd one not wrking - PythonBeginner_2020 - Mar-25-2020 Hi All, i hame on simple code. same code is working when i am using customer specific tool command . but same code is not working on other command, example:- mycommand1 --is working, with in python and on window cmd prompt when i test it manually mycommand2 --is not working in python , but working on cmd prompt but its taking 20-40 second to exceute on command prompt while testing it manually ,is it because of delay this code is not working on mycommand2 ? import subprocess as sp a=sp.run('mycommand',shell = True) rc=a.returncode print("This is returen code {}".format(rc)) if (rc==0): print("Command working fine") output = sp.run('mycommand',capture_output = True, text = True) print(output.stdout) else: print("There is error in this command")-------------
|