I have written the following script: (I meant to use Net-Ping but I didn't have time to read its docs) (and I run this on linux boxes occasionally so that's the shebang and yes I change the -n to a -c)

#!/usr/bin/perl -w use strict ; use diagnostics ; use LWP::Simple ; #this will run a ping to our firewall #to yahoo.com #to 132.163.4.101 an NIST Time Server #and with get the time (UTC) #run this script piped to text from the prompt my $ping1 = (`ping XXX.XXX.XXX.XXX -n 1`) ; my $ping2 = (`ping yahoo.com -n 25`) ; my $ping3 = (`ping 132.163.4.101 -n 25`) ; my $numb = 51 ; until ($numb == 1) { chomp $numb ; $numb -- ; print "R---------------------------\n" ; print $ping1 ; print "Y---------------------------\n" ; print $ping2 ; print "I---------------------------\n" ; print $ping3 ; print "T---------------------------\n" ; getprint "http://132.163.4.101:13 \n" ; print "E---------------------------\n" ; }


It produces this output: (edited for content!)

P--------------------------- Pinging XXX.XXX.XXX.XXX with 32 bytes of data: Reply from XXX.XXX.XXX.XXX: bytes=32 time<10ms TTL=63 Ping statistics for XXX.XXX.XXX.XXX: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms P--------------------------- Pinging yahoo.com [216.115.108.245] with 32 bytes of data: Reply from 216.115.108.245: bytes=32 time=70ms TTL=237 ... Reply from 216.115.108.245: bytes=32 time=90ms TTL=237 Ping statistics for 216.115.108.245: Packets: Sent = 25, Received = 25, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 70ms, Maximum = 90ms, Average = 72ms P--------------------------- Pinging 132.163.4.101 with 32 bytes of data: Reply from 132.163.4.101: bytes=32 time=90ms TTL=39 ... Reply from 132.163.4.101: bytes=32 time=111ms TTL=39 Ping statistics for 132.163.4.101: Packets: Sent = 25, Received = 25, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 90ms, Maximum = 111ms, Average = 92ms T--------------------------- 52138 01-08-17 22:08:06 50 0 0 404.0 UTC(NIST) * T---------------------------


I would like the final output to look like this:

Reply from XXX.XXX.XXX.XXX: bytes=32 time<10ms TTL=63 ------------------------------------------------------- Reply from 216.115.108.245: bytes=32 time=70ms TTL=237 ... Reply from 216.115.108.245: bytes=32 time=90ms TTL=237 Average = 72ms ------------------------------------------------------- Reply from 132.163.4.101: bytes=32 time=90ms TTL=39 ... Reply from 132.163.4.101: bytes=32 time=111ms TTL=39 Average = 92ms ------------------------------------------------------- 52138 01-08-17 22:08:06 50 0 0 404.0 UTC(NIST) * -------------------------------------------------------


I pipe the output to text in a file called (imaginatively) ping.txt so I am thinking that I should write another script to pull the info I want out. Or possibly do some sort of manipulation at the end of the until loop? This is one of those case where I know exactly what I want and have NO IDEA how to get it. any ideas? pointers? perldocs? how would you do it?
--
lmoran@wtsgSPAM.com
print "\x{263a}"

In reply to Getting the text I want by ellem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.