python nmap for loop

SS sami.strat at gmail.com
Wed Jun 14 11:02:58 EDT 2017


I'm trying to make the following code work:

import os, sys

app=['host1', 'host2', 'host3']

for i in app:
    os.system('nmap -p 22 -P0 %s | grep open 2>&1 > /dev/null && echo "%s up"


I've tried many different iterations of the os.system call, how to make this work?

TIA



More information about the Python-list mailing list