LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   stdout capture anb bring to file (https://www.linuxquestions.org/questions/programming-9/stdout-capture-anb-bring-to-file-71367/)

sqn 07-09-2003 05:04 PM

stdout capture anb bring to file
 
I want to make a script that will capture/serch for a specified string in the stdout of a program and put it in a file:
example
i give a ping command to a host and the reply with 0% pachets lost/100% pakets lost i need to put it in a file witch will b emaild to later. The problem is how can i capture that reply?

Thx in advance

PS I use pure shell script

Pres 07-09-2003 08:38 PM

This is too simple I suppose :

ping 192.168.1.1 > /root/grepin
grep -n "packet loss" /root/grepin > /root/grepout

If it's not flexible enough you could go with variables instead.

sqn 07-10-2003 08:42 AM

thx a lot
It's working fine


All times are GMT -5. The time now is 03:39 AM.