Hi,

   +-From: Vijaya Natarajan <v...@hpcrd.lbl.gov> --
   |_Date: Tue, 09 Aug 2011 14:58:14 -0700 __
   |
   |I am following the suggestions given in this reply to use
   |tar -c -f -z folder to speed up the download transfers.
   |I tried it in my program, it is said just send the output to std output
   |and later piped and save it in a file.
   |Is there any example to show how to do that. I would really appreciate that.

Suppose that if you want to do following ssh command operations in JSch APIs,
  $ ssh f...@example.com "(cd /usr; tar czf - src)" > /tmp/foo.tgz
how about following chunk of code?

   Channel channel=session.openChannel("exec");

   String command="(cd /usr; tar czf - src)";
   ((ChannelExec)channel).setCommand(command);

   java.io.FileOutputStream out = new java.io.FileOutputStream("/tmp/foo.tgz");
   channel.setOutputStream(out);
   channel.setInputStream(null);
   ((ChannelExec)channel).setErrStream(System.err);

   channel.connect();

   while(true){
     if(channel.isClosed()){
       System.out.println("exit-status: "+channel.getExitStatus());
       break;
     }
     try{Thread.sleep(1000);}catch(Exception ee){}
   }
   channel.disconnect();

   out.close();


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
Skype callto://jcraft/
Twitter: http://twitter.com/ymnk
Facebook: http://facebook.com/aymnk

------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to