I was using os.system for shell commands until I discovered it's deprecated. So I am trying to switch to using subprocess. Here are my uses:
command = genConfig.MODETECT_SWITCH_COMMAND.append(state)
subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0]
MODETECT_SWITCH_COMMAND = ["zmpkg.pl"]
and some regular pings:
command = genConfig.PING_COMMAND.append(host)
response = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0]
if "unreachable" in response or "timed out" in response:
response = False
else:
response = True
break
PING_COMMAND = ["ping", "-c 1 -W 1"]
Everywhere I do these things, I get this error:
...tracebacks...
File "/usr/lib/python2.7/subprocess.py", line 1198, in _execute_child
args = list(args)
TypeError: 'NoneType' object is not iterable
And I can't figure out why. I've rechecked my use of subprocess.popen multiple places and it seems to be correct. What might I be doing incorrectly? Thanks.