Sunday, 15 September 2013

Calling nc/netcat in python with variable

Calling nc/netcat in python with variable

I am attempting to call netcat/nc from inside a loop, passing the lcv as
the last octet in the command. I am seem to be running into an issue due
to the fact that the variable is in the middle of the command. What I
would like to do is:
for i in 1 to 50
print i
nc -nvv 192.168.1.i 21 -w 15 >> local_net.txt
So far I have tried:
os.system("nc -nvv 192.168.1.",i,"21 -w 15 >> local_net.txt")
and
subprocess.call(["nv","-nvv 192.168.1.",i,"21 -w 15 >> local_net.txt")
Is there an easier way to reference an LVC from within a command executing
a system command?

No comments:

Post a Comment