hello all,

trying out on how to port my unix shell script to python.
get more complicated than i expected.....: (
i am not familiar with the modules available in python.

anyone care to share how to better the clumsy approach below.

regards,
kuenn


                timestamp02 = time.strftime("%Y-%m-%d-%H%M%S")
banIPaddressesFile = os.popen("cat /var/log/fail2ban.log| egrep ssh| egrep Ban| egrep " + myDate + "| awk \'{print $7}\'| sort -n| uniq >/tmp/banIPaddressesFile." + timestamp02).read() banIPaddresses = open("/tmp/banIPaddressesFile." + timestamp02,mode="r",encoding="utf-8")
                print("banIPaddresses:")
                print(banIPaddresses)
                for banIP in banIPaddresses:
                        #print("banIP:", banIP)
                        banIP1 = banIP.rstrip("\n")
                        print("BanIPaddress:", banIP1)
whoisIP = os.popen("whois -H " + banIP1 + " |egrep -i \"name|country|mail\" |sort -n |uniq").read()
                        print("whoisIP:", whoisIP)

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to