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

  • SEARCH
  • Home
  • 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 7159015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:09:39+00:00 2026-05-28T13:09:39+00:00

I am looking for libraries that I can use to send Unix commands from

  • 0

I am looking for libraries that I can use to send Unix commands from my Java code. I have already tried Expect4J and Gaynmed, but could not find good documentation with them. My requirements include:

  1. Running multiple commands.
  2. Capture output for previous command.
  3. Take some action/Run different command based on output of last command.

Any pointers will be appreciated.

  • 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-28T13:09:40+00:00Added an answer on May 28, 2026 at 1:09 pm

    Looking at the names of the libraries you mentioned, it seems like you want to run the commands on a remote server using ssh.

    Check out http://code.google.com/p/sshxcute/

    Code is pretty easy

    // Initialize a ConnBean object, parameter list is ip, username, password
    ConnBean cb = new ConnBean("ip ", "username","password");
    // Put the ConnBean instance as parameter for SSHExec static method getInstance(ConnBean) to retrieve a singleton SSHExec instance
    ssh = SSHExec.getInstance(cb);          
    // Connect to server
    ssh.connect();
    CustomTask sampleTask = new ExecCommand("echo 123");
    ssh.exec(sampleTask);
    

    Getting the output is easy too. Just check the link I provided.

    Result res = ssh.exec(task); 
    if (res.isSuccess) {
        System.out.println("Return code: " + res.rc);
        System.out.println("sysout: " + res.sysout);
    } else {
        System.out.println("Return code: " + res.rc);
        System.out.println("error message: " + res.error_msg);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a secure templating language for Java that business users can use.
I am looking for any libraries in java that can parse an address out
I'm looking for a Sparse Matrix library I can use from Ruby. I'm currently
I am looking for template/generator libraries for C++ that are similar to eg. Ruby's
I've been looking around JQuery libraries for the URL hash, but found none that
What OCaml libraries are out there that provide lazy list handling? I am looking
I am looking to generate ruby modules from existing C libraries. In the past,
I know there are a few questions regarding the libraries you can use to
I'm looking for a javascript charting library that can display interactive bar graphs on
I am looking for a library or set of libraries that will help me

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.