I am trying to implement the below from python using subprocess but getting stuck:
Within a python script I would like to do the below and echo to linux.
varname = "namegoeshere"
varvalue = "12345"
echo "varname varvalue date +%s" | nc 127.0.0.1 2003
I expect that everything after the echo is run on the linux command prompt.
This is what I get
Traceback (most recent call last):
File "test.py", line 9, in <module>
subprocess.call("echo " , varname , varvalue, "date +%s ", "|" , "nc " , server , " " , port )
File "/usr/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 659, in __init__
raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer