-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to save the results in a variable? #59
Comments
As you mentioned in your code, Beside, you can use the following code to save the ping result. # verbose_ping
with redirect_stdout(output):
verbose_ping(dest_addr=dest_addr, count=duration, interval=1, src_addr=src_addr)
# ping
import time
for i in range(duration): # count=duration
delay = ping(dest_addr=dest_addr, src_addr=src_addr, unit="ms")
log_ping_to_file(filename, "ping ... from ... " str(delay)) # write the delay to your log file
time.sleep(1) # interval=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using the ping3 module in separate threads for every interface in the machine by the help of threading module.
Ping3 module gives the system output/prints to the screen. For that reason, I'm trying to get the system output in a variable using io module. In these case, instead of saving the output to the separate files for every thread/IP, all the outputs will be saved in a single file.
Instead of getting the output using alternative methods, is it possible to save the verbose_ping output directly to a variable? When I tried this, it returns NoneType variable.
You can see the snippets below.
It's the function that I get the results using io module.
Output file. The logs should have saved in to different files separated by IP address its send from.
ping 'google.com.tr' from '192.168.0.243' ... 62ms ping 'google.com.tr' from '192.168.0.108' ... 62ms ping 'google.com.tr' from '192.168.0.237' ... 62ms ping 'google.com.tr' from '192.168.0.243' ... 37ms ping 'google.com.tr' from '192.168.0.108' ... 84ms ping 'google.com.tr' from '192.168.0.237' ... 84ms ping 'google.com.tr' from '192.168.0.243' ... 31ms ping 'google.com.tr' from '192.168.0.108' ... 56ms ping 'google.com.tr' from '192.168.0.237' ... 56ms ping 'google.com.tr' from '192.168.0.243' ... 64ms ping 'google.com.tr' from '192.168.0.108' ... 30ms ping 'google.com.tr' from '192.168.0.237' ... 80ms ping 'google.com.tr' from '192.168.0.243' ... 29ms ping 'google.com.tr' from '192.168.0.108' ... 35ms ping 'google.com.tr' from '192.168.0.237' ... 30ms ping 'google.com.tr' from '192.168.0.243' ... 33ms ping 'google.com.tr' from '192.168.0.108' ... 28ms ping 'google.com.tr' from '192.168.0.237' ... 28ms ping 'google.com.tr' from '192.168.0.243' ... 20ms ping 'google.com.tr' from '192.168.0.108' ... 31ms ping 'google.com.tr' from '192.168.0.237' ... 22ms ping 'google.com.tr' from '192.168.0.243' ... 31ms ping 'google.com.tr' from '192.168.0.108' ... 22ms ping 'google.com.tr' from '192.168.0.237' ... 31ms ping 'google.com.tr' from '192.168.0.243' ... 29ms ping 'google.com.tr' from '192.168.0.108' ... 31ms ping 'google.com.tr' from '192.168.0.237' ... 53ms ping 'google.com.tr' from '192.168.0.243' ... 32ms
Thanks for your help.
The text was updated successfully, but these errors were encountered: