-1
pythonスクリプトで次のコマンドを実行する方法は?Pythonスクリプトにbashコマンドを実行
echo "show stat" | socat unix-connect:/var/run/haproxy/admin.sock stdio | grep webservers,BACKEND | cut -d , -f8
私はこの
import subprocess
var = subprocess.check_output(echo "show stat" | socat unix-connect:/var/run/haproxy/admin.sock stdio '| grep ' webservers,BACKEND' | cut -d , -f8', shell=True)
var=int(var)
を試みたが、それは動作しません!
'VAR = subprocess.check_output( """エコー "ショースタット" | UNIX-接続socatに関する:/var/run/haproxy/admin.sockのstdioの '| grepを' Webサーバー、BACKEND '| cut -d、-f8' "" "、shell = True)' –
この質問を確認するhttp://stackoverflow.com/questions/27911820/python-subprocess-with-quotes-and-pipe-grep –
コマンドではなく文字列を渡す必要があります。 – asimoneau