Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7591341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:37:42+00:00 2026-05-30T20:37:42+00:00

I am using a jsch library to connect to a server using ssh connection.

  • 0

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.

e.g.

ping 192.168.0.128

Then it starts printing out in the console the response which is a string and looks as follows:
– successful ping:

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

-unsuccessful ping:

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

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:37:43+00:00Added an answer on May 30, 2026 at 8:37 pm

    On your channel object call getExitStatus(), if it is equal to 0 then the connection was successful, if it was equal to 1 then the connection was not successful.

    See http://linux.die.net/man/8/ping for the exit codes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ssh tools to make a ssh connection to a school server,
i am using jsch to get ssh output from a local ssh server. When
I'm currently using JSch as the library for connecting to my remote server. In
Using the library to connect to a remote server and copy a file. I
I'm using JSch to get files from an SFTP server, but I'm trying to
I'm trying to connect to SSH Unix server on button click (code written in
I am using java ssh tools to make an ssh connection to my school
I am using JSCH library to do a sftp between two servers. But, I
I am new to SSH and JSch. When I connect from my client to
I am using the nice http://www.jcraft.com/jsch/ library - however when I run some commands,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.