Hello,
The following works fine for me from a jsp
<% try{
JSch jsch=new JSch();
String host="[EMAIL PROTECTED]";
String user=host.substring(0, host.indexOf('@'));
host=host.substring(host.indexOf('@')+1);
Session sessionJSH=jsch.getSession(user, host, 22);
sessionJSH.setPassword("alliacom");
java.util.Hashtable configJSH=new java.util.Hashtable();
configJSH.put("StrictHostKeyChecking", "no");
sessionJSH.setConfig(configJSH);
sessionJSH.connect();
Channel channel=sessionJSH.openChannel("shell");
channel.setInputStream(System.in);
channel.setOutputStream(System.out);
channel.connect();
channel.disconnect();
sessionJSH.disconnect();
}
catch(Exception e){
System.out.println(e);
} %>
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;
String command="mkdir my_distant_path/test";
Channel channel=sessionJSH.openChannel("exec");
((ChannelExec)channel).setCommand(command);
channel.connect();
channel.disconnect();
sessionJSH.disconnect();
what's wrong with that code ?
Thanks
lm
-------------------------------------------------------------------------
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