[Tutor] IPcount = 0 when used with subprocess.call (use something to convert to integer?)

Rogelio scubacuda at gmail.com
Tue May 8 05:09:55 CEST 2012


I am wrapping a Python wrapper script to "wc -l" (count lines) of a
list of IP addresses

*******************************************

import subprocess
IPcount = subprocess.call(['wc -l file.txt | awk \'{print $1}\''], shell=True)
print "You have",IPcount,"IP addresses that are alive."

*******************************************

I get the following output

*******************************************
46
You have 0 IP addresses that are alive.
*******************************************

Why does IPcount not equal 46?  Is this what the stout is for?


More information about the Tutor mailing list