What is this extra tuple from Popen in python? -
i'm little confused on what's happening. want count how many lines returning see if process running or not. i'm using subprocess.popen run command can output. however, while testing script, i'm seeing additional output didn't count on , i'm curious why , how suppress it.
here's snippet script. please excuse typos me sanitizing it.
ssh = subprocess.popen("ssh " + host + " ps -ef | grep jetty | wc -l", stdin=subprocess.pipe, shell=true) output = ssh.communicate() print output
the output of script is:
1 (none, none)
the docs communicate returns tuple (stdoutdata, stderrdata). why returning 1 , (none, none)? how suppress (none, none) line/message?
in order references command's standard output and/or standard error, have pass subprocess.pipe
value of stdout
, stderr
(respectively) keyword arguments. otherwise, value of none
returned in tuple. since didn't specify value stdout
, output of command goes python script's standard output, why see "1".
Comments
Post a Comment