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 6092259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:25:19+00:00 2026-05-23T12:25:19+00:00

How can I run an application on a remote machine via ssh? I tried

  • 0

How can I run an application on a remote machine via ssh?

I tried using JSCH, this way:

    Properties props = new Properties();
    props.put("StrictHostKeyChecking", "no");

    String host = "111.111.11.111";
    String user = "myuser";
    String pwd = "mypass";
    // int port = 22;

    JSch jsch = new JSch();
    Session session = jsch.getSession(user, host);
    session.setConfig(props);
    session.setPassword(pwd);
    session.connect();

    System.out.println(session.getServerVersion());
    System.out.println("Conected!");

    // String command = "ps -ef;date;hostname";

    String command = "myapplication  someFileAsParameter";
    Channel channel = session.openChannel("exec");
    ((ChannelExec) channel).setCommand(command);

    // channel.setInputStream(System.in);
    channel.setInputStream(null);

    ((ChannelExec) channel).setErrStream(System.err);

    InputStream in = channel.getInputStream();

    channel.connect();

and I have this:

bash: myapplication: command not found

When try execute this command by shell, works fine.

Not necessarily needs to be JSCH, can be anything.

  • 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-23T12:25:20+00:00Added an answer on May 23, 2026 at 12:25 pm

    For future readers: As shown by the discussion, the reason was that JSch connected to a different server than normal SSH (and one of these had the file, while the other one had not). I still let my answer here, as it contains some useful (I think) debugging ideas for similar problems. But remember: First check that you are connecting to the right computer.


    In principle, this is the way to do it, if you use JSch. If you get the error message bash: myapplication: command not found, this means that there was no myapplication binary in the path. (And you will get the same error message when using plain command line ssh.)

    Try which myapplication (or type myapplication) in your normal shell, to see where it is located. Then use echo $PATH >&2 as the command, to see the path used by your exec channel. It could be that this is different then when executed from your normal shell. If so, either use the full path in the command name, or fix your setup. (Look wether the path is set in ~/.bashrc, ~/.profile, /etc/profile or /etc/bash.bashrc. Only some of these files will get executed on a interactive versus noninteractive login – and exec channel will be noninteractive, I think.)

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

Sidebar

Related Questions

I would like to run an application passing it arguments from a remote machine.
I have a delphi (Win32) web application that can run either as a CGI
I have a C#/.NET program that can run both as a console application and
I can run the server on my local machine and connect to it on
Is there a way you can run your UnitTest project against a compiled DLL
can somebody please tell me where i m wrong why this RMI chat application
With AdHoc provisioning profile I can't start my application on iPhone. I get this
Summary: query registry on remote machine capture output to use in application needs to
I want to use Fabric.api.run to directly start an application in a remote box.
in this application i am running a remote service where i am starting a

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.