Hello,
 I've got the following jsp that works fine .... but only once ! If y
re-submit the page, code is no more executed (can't see "file already
exists" in the logs).

Could it be some kind of session persistence ?

Thanks

<%@ page import="com.jcraft.jsch.*,java.io.*,java.util.*" %>
 <%   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();
      Date date = new Date();
      System.out.println("commande ok "+date);
      out.println("commande ok "+date);
      String command="mkdir
/usr/local/jakarta-tomcat-4.1.29/webapps/test";
      Channel channel=sessionJSH.openChannel("exec");
      ((ChannelExec)channel).setCommand(command+"\n");
      ((ChannelExec)channel).setErrStream(System.err);
      InputStream in=channel.getInputStream();
      channel.connect();
      byte[] tmp=new byte[1024];
      while(true){
        while(in.available()>0){
          int i=in.read(tmp, 0, 1024);
          if(i<0)break;
          System.out.print(new String(tmp, 0, i));
        }
        if(channel.isClosed()){
          System.out.println("exit-status: "+channel.getExitStatus());
          break;
        }
        try{Thread.sleep(1000);}catch(Exception ee){}
      }
      channel.disconnect();
      sessionJSH.disconnect();
    } 
    catch(Exception e){
     System.out.println(e);
    }    %>

-------------------------------------------------------------------------
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

Reply via email to