I want my code to take the i/p and o/p file names, ping all websites present in the i/p file, and display "pingable" or "not pingable" in the output file. It must not display any ping results. I don't want to use subprocess. All commands must support command prompt(windows).
The code is working fine but the ping results are displayed on execution. I don't want it to be displayed.
i tried to redirect the result to a document called trash.txt, but it doesn't seem to work.
import os
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
fname1 = input('Enter the file name to read: ')
fname2=input('enter filenme to write:')
finp = open(fname1,'r')
fout=open(fname2,'w')
for line in finp:
 os.system('@ECHO OFF')
 response=os.system('ping -n 1 '+line+' > trash.txt')
if response==0:
     os.system('echo ok')
     fout.write(line+'\tis pingable\n')
 else:
     fout.write(line+'\tis not pingable\n')
 
    