そのため、コマンドの出力を変数に格納しようとしています。コマンドの実行中に出力を表示したくないのですが...
私が今持っているコードは次のとおりです...
def getoutput(*args):
myargs=args
listargs=[l.split(' ',1) for l in myargs]
import subprocess
output=subprocess.Popen(listargs[0], shell=False ,stdout=subprocess.PIPE)
out, error = output.communicate()
return(out,error)
def main():
a,b=getoutput("httpd -S")
if __name__ == '__main__':
main()
これをファイルに入れてコマンドラインで実行すると。コードに print ステートメントがなくても、次の出力が得られます。出力を保存しながら、どうすればこれを防ぐことができますか?
#python ./apache.py
httpd: Could not reliably determine the server's fully qualified domain name, using xxx.xxx.xxx.xx for ServerName
Syntax OK