Hi,
+-From: "Marot Laurent" <[EMAIL PROTECTED]> --
|_Date: Fri, 23 May 2008 17:13:29 +0200 _______________
|
|But now i'd like to send simple command like mkdir / cp / .... launch
|shell script on distant server. I used to think that the following woudl
|have worked but it does not;
...
| Channel channel=3DsessionJSH.openChannel("exec");
| ((ChannelExec)channel).setCommand(command);
InputStream in=channel.getInputStream();
| channel.connect();
How about waiting for the end of execution of 'command'?
Refer to http://www.jcraft.com/jsch/examples/Exec.java
byte[] tmp=new byte[1024];
while(true){
while(in.available()>0){
int i=in.read(tmp, 0, tmp.length);
if(i<0)break;
}
if(channel.isClosed()){
//System.out.println("exit-status: "+channel.getExitStatus());
break;
}
try{Thread.sleep(1000);}catch(Exception ee){}
}
| channel.disconnect();
| sessionJSH.disconnect();
Sincerely,
--
Atsuhiko Yamanaka
JCraft,Inc.
1-14-20 HONCHO AOBA-KU,
SENDAI, MIYAGI 980-0014 Japan.
Tel +81-22-723-2150
+1-415-578-3454
Fax +81-22-224-8773
Skype callto://jcraft/
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users