Answer the question
In order to leave comments, you need to log in
How to run bash script from python?
Hello.
Please tell me how to properly run the bash script that is on the computer through the telegram bot, which is written in python and get a response from it?
If you run the script itself through python, it works, but it crashes through the bot, I can’t figure out how to properly organize the output of the result.
In a normal python script, I did this:
import subprocess
subprocess.call("test.sh")
Answer the question
In order to leave comments, you need to log in
proc = subprocess.Popen('./test.sh', stdout=subprocess.PIPE)
output = proc.stdout.read()
print output
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question