Jul-24-2019, 01:08 AM
Do anyone know how to export the log file? i run this script, it will run on the cmd prompt but i also wish to log on a file. Is there nay possible method to export on a file in the same time wit will show on the prompt.
This is my script
This is my script
import os
import time
import datetime
count=0
cycle=1000
now = datetime.datetime.now()
hostname_IP = input("enter your ip address(host):")
cycle = input("please enter how many cycle?(default is 1000) ")
cycle = int(cycle)
print ("==================start==============")
print ("===============Current date and time : ",time.strftime("%a, %d %b %Y %H:%M:%S"),"===============")
for i in range (cycle):
response = os.system("ping -n 5 " + hostname_IP + " | FIND " + '"TTL="')
time.sleep(60)
if response == 0:
count =count+1
print ("###result:PASS###",count)
else:
print ("result:FAIL")
break
print ("==================end==============")
os.system("pause")
