I want to write information about this tracing in file:
site = input('Input URL:')
trac = os.system('tracert '+site)
but trac
equals 0 and I don't know how to get access to os.system() information.
I want to write information about this tracing in file:
site = input('Input URL:')
trac = os.system('tracert '+site)
but trac
equals 0 and I don't know how to get access to os.system() information.
Here :
trac = os.system('tracert '+site)
the return value is :
Linux
On Unix, the return value is the exit status of the process encoded in the format specified for wait().
or
Windows
On Windows, the return value is that returned by the system shell after running command, given by the Windows environment variable COMSPEC.
For more information about that see python's documentation about os.system.
But if you want to retrieve outputs of your system call then use subprocess.check_output method of subprocess module instead and try to change your code like that :
import subprocess
site = input('Input URL:')
trac = subprocess.check_output(["tracert", site])
# Do something else
Formerly you can did it with os.popen but since Python 2.6 it's deprecated :
Deprecated since version 2.6: All of the popen*() functions are obsolete. Use the subprocess module.