Looks like none of my posts have gotten through, so I'm guessing there's a big 
backlog of posts waiting to be reviewed, for an unmaintained project.

 

Nonetheless, here is my latest problem: Exec is giving me read access, but not 
write access. I can 'pwd' and 'ls' all I want, and even pipe ls into head, but 
I can't mv or touch anything. The cmds don't generate output or stderr, but 
nothing happens.

 

I also tried putting my key in .ssh/known_hosts and connecting without a 
password, but that failed.

 

Bill

 

From: Bill Ross 
Sent: Thursday, March 15, 2012 5:53 PM
To: 'jsch-users@lists.sourceforge.net'
Subject: RE: problems with jsch Exec.java demo

 

Maybe my earlier 2 posts have been waiting for moderation? Anyway, I thought 
I'd throw a solution along too, in case this ever gets out J

 

InputStream in=channel.getInputStream();

BufferedReader fromServer = new BufferedReader(new InputStreamReader(in));

channel.connect();

System.out.println(fromServer.readLine());

 

Thanks to code for jsch Shell:

 

    http://blog.james-carr.org/2006/07/11/ssh-over-java/

 

Bill

 

From: Bill Ross 
Sent: Thursday, March 15, 2012 9:07 AM
To: 'jsch-users@lists.sourceforge.net'
Subject: RE: problems with jsch Exec.java demo

 

I'm sending this again since I sent it right after joining and didn't receive a 
copy, so not sure if it went out.

 

Has anyone gotten output from jsch-0.1.46/examples/Exec.java?

 

It seems like there might also be a bug with java since the main() never 
completes.

 

Bill

 

From: Bill Ross 
Sent: Wednesday, March 14, 2012 5:14 PM
To: 'jsch-users@lists.sourceforge.net'
Subject: problems with jsch Exec.java demo

 

The Jsch 1.46 Exec demo isn't working for me, in that output of the 
remote-execd-cmd (pwd) is getting lost. I can see it if I print the raw 
buffers, but my InputStream has gotten the output  only once out of 30 tries. 
Also the program exits after the exec is done and before the rest of the demo 
program's main() can run,  even though I can't find any System.exit's in the 
jsch code. Example code and output below.

 

Has anyone gotten the Exec functionality to work?

 

Thanks,

Bill

 

Code from Exec.java, with printlns added:

 

      byte[] tmp=new byte[1024];

      while(true){

        System.out.println("=========== get " + in.available() + " cclosed " + 
channel.isClosed()); // normally 0/false

 

        while(in.available()>0){

          int i=in.read(tmp, 0, 1024);

          System.out.println("got " + i);

          if(i<0)break;

          System.out.print(new String(tmp, 0, i));

        }

        if(channel.isClosed()){

          System.out.println("### exit-status: "+channel.getExitStatus()); // 
not printed

          break;

        }

        try{Thread.sleep(100);}catch(Exception ee){}

      }

System.out.println("disconnecting"); // not printed

      channel.disconnect();

      session.disconnect();

    }

 

Result:

 

Session.read()

ChannelExec start() cmd pwd

RequestExec.request() written ok

=========== get 0 cclosed false

=========== get 0 cclosed false

=========== get 0 cclosed false

Session.read() **if I print the buffer here, I can see the result of pwd:**

read [^

       /home/xoom

ā–’Sā–’eā–’>]

Session.run() got exit-status: 0

Session.read()

Session.read()





---------------------------------------------------------------------------------
The information transmitted in this email is intended only for the person or 
entity to which it is addressed, and may contain material confidential to Xoom 
Corporation, and/or its subsidiary, buyindiaonline.com Inc.  Any review, 
retransmission, dissemination or other use of, or taking of any action in 
reliance upon, this information by persons or entities other than the intended 
recipient(s) is prohibited.   If you received this email in error, please
 contact the sender and delete the material from your files.

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to