determine whether ping has been sent successfully
<p>I am using a jsch library to connect to a server using ssh connection. Then I open an "exec" channel to execute a ping command to ping other devices connected to that server.</p>

<p>e.g.</p>

<pre><code>ping 192.168.0.128
</code></pre>

<p>Then it starts printing out in the console the response which is a string and looks as follows:
- successful ping: </p>

<pre><code>PING 192.168.0.128 (192.168.0.128) 56(84) bytes of data.
64 bytes from 192.168.0.128: icmp_req=1 ttl=64 time=0.253 ms
64 bytes from 192.168.0.128: icmp_req=2 ttl=64 time=0.231 ms
</code></pre>

<p>-unsuccessful ping:</p>

<pre><code>PING 192.168.0.126 (192.168.0.126) 56(84) bytes of data.
From 192.168.0.7 icmp_seq=1 Destination Host Unreachable
From 192.168.0.7 icmp_seq=2 Destination Host Unreachable
</code></pre>

<p>How can I handle the output to determine programmatically whether the connection has been successful or not? A regexp pattern?</p>
