Monday 15 August 2011

python subprocess with /dev/zero input -



python subprocess with /dev/zero input -

i'm trying write in python next command : netcat ip port < /dev/zero works in terminal , far attempts in python failed miserably hints please ?

fd = os.open("/dev/zero", os.o_rdonly); buf = os.read(fd, 1024) os.close(fd) ip='192.168.1.45' port= 56 netc =subprocess.popen(['netcat',ip,str(port)],stdin=buf)

stdin needs python file object. fortunately, there 1 handy...

import subprocess ip='192.168.1.45' port= 56 open("/dev/zero", "rb", 0) file: netc = subprocess.popen(['netcat', ip, str(port)], stdin=file)

python subprocess

No comments:

Post a Comment