Your command will run on shell/terminal. So you need to take shell first
the run your command

String[] cmd = {"/bin/sh",
"-c",
                         "ssh -t -o ProxyCommand ssh fox@10.0.0.1 nc %h %p
22 ubuntu@10.0.0.22 ls -l"};



On Tue, Dec 22, 2015 at 9:14 PM, Mohamed Boussaa <mohamedbouss...@gmail.com>
wrote:

> I am running this command on my mac terminal :
>
> ssh -t -o "ProxyCommand ssh fox@10.0.0.1 nc %h %p 22" ubuntu@10.0.0.22
> "ls -l"
>
> It works. But when I run it like below in eclipse:
>
>   List<String> result = new ArrayList<String>();
>
>   java.lang.Process pp;
>
>         try {
>
>             pp = Runtime.getRuntime().exec("ssh -t -o ProxyCommand ssh
> fox@10.0.0.1 nc %h %p 22 ubuntu@10.0.0.22 ls -l");
>
>             pp.waitFor();
>
>             BufferedReader br = new BufferedReader(new
> InputStreamReader(pp.getInputStream()));
>
>             String line = "";
>
>             while ((line = br.readLine()) != null) {
>
>             System.out.println("line :"+line);
>
>                 result.add(line);
>
>             }
>
>         } catch (IOException e) {
>
>             e.printStackTrace();
>
>         } catch (InterruptedException e) {
>
>             e.printStackTrace();
>
>         }
>
>
> It doest not work and does not print any thing on the console.
>
> Do you have an idea ?
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> JSch-users mailing list
> JSch-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jsch-users
>
------------------------------------------------------------------------------
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to