[英]Using Python to ssh then run bash script. The output of the running bash script i need to display on the screen
[英]I have one shell script which I want to run via python script. I tried doing so using subprocess or os module , but nothing worked
cd='np07lvg7omtn77s_APPID'
cs='10f22edb0-ab0bc-4b82-b765-bb5927567118'
b=`echo -n "$cd:$cs" | base64 -w 0`
echo $b
以上是我想通過 python 腳本運行的 shell 腳本。我得到的 output 為 250。你能幫我嗎?
import subprocess
proc = subprocess.Popen(['test.sh'], shell=True, stdout=subprocess.PIPE)
try:
outs, errs = proc.communicate(timeout=15)
except TimeoutExpired:
proc.kill()
outs, errs = proc.communicate()
print(outs)
將 test.sh 替換為 shell 腳本的路徑
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.