Hey folks, I’m trying to create a program to ping one of my company’s
computers every minute to measure latency, and output the results to a
text file. I’ve been able to figure out / cobble together most of what
I need (see attached ping.rb file) but the problem i’m having is I
cannot figure out how to get Ruby to copy the results from the ping to
the text file that is created.
What I get currently when I run the program (from the log file):
Wed Sep 17 13:52:45 -0500 2008
System Ping Monitor:
Wed Sep 17 13:52:45 -0500 2008
The “ping” command doesn’t output the way I need it to, HALP!!
hrm, I’ve tried looking over the documentation in the link you
provided, but I’m having difficulty understanding it. Could you provide
an example of the code?
hrm, I’ve tried looking over the documentation in the link you
provided, but I’m having difficulty understanding it. Could you provide
an example of the code?
thanks again,
~Tony
This won’t work (even when you remove the typo .to_S):
f.puts system(‘ping 192.168.1.74’).to_S
The ping will be executed, but you are logging if it succeeded, not the
output.
Erik is pointing to a working solution: