[lug] Bash Scripting Ping

Chan Kar Heng chankarheng at gmail.com
Sun Nov 8 11:12:46 MST 2020


Hi. You could use ping -c 1 within a while loop to get output of each ping & process it?

Best regards,
kh


On 9 November 2020 02:10:36 GMT+08:00, "D. Stimits" <stimits at comcast.net> wrote:
>> 
>>     For those of me who're first reading your question while sitting
>in a coffee shop at a Mac laptop, could you just say what the flags are
>doing, so's I can make sure I understand the problem by trying
>something similar?
>> 
>I'm just listing the time in microseconds (which can be converted to a
>date, and is in fact one of the things I wanted to edit...changing
>microseconds to a date stamp), plus making sure no two pings are issued
>simultaneously (not normally a problem, but in bad network conditions
>it would be possible to issue two pings before either had
>returned...think of it as guaranteeing serialized pings).
>
>>     On Sun, Nov 8, 2020 at 10:53 AM D. Stimits < stimits at comcast.net
>mailto:stimits at comcast.net > wrote:
>> 
>>         > >         I am curious about something in bash scripting
>which does not seem to be particularly easy. I wanted to script "ping
>-O -D address" such that each line gets processed by some logic if the
>ping fails. Redirecting ping to a variable does not work because it
>only "returns" when the ping exits (each line is not an exit). Even if
>I were to fork and exec, the forked process would itself have the same
>problem.
>> > 
>> >         Is there some simple/clever way to process each line of a
>ping in bash without killing off the ping itself? My goal was to send
>it through some database and statistics type processing as
>success/failure lines occur.
>> >         _______________________________________________
>> >         Web Page:  http://lug.boulder.co.us
>> >         Mailing List:
>http://lists.lug.boulder.co.us/mailman/listinfo/lug
>> >         Join us on IRC:http://irc.hackingsociety.org port=6667
>channel=#hackingsociety
>> > 
>> >     > 
>> 
>>     --
>>     Jeffrey Haemer < jeffrey.haemer at gmail.com
>mailto:jeffrey.haemer at gmail.com >   720-837-8908 [cell]
>> 
>> 
>>      פרייהייט? דאס איז יאַנג דינען וואָרט!
>> 
>>     _______________________________________________
>>     Web Page: http://lug.boulder.co.us
>>     Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
>>     Join us on IRC: irc.hackingsociety.org port=6667
>channel=#hackingsociety
>> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20201109/1d608897/attachment.html>


More information about the LUG mailing list