Hi,
 
Please note my source code below:
 
Session ftpSession = null;
  Channel channel = null;
  ChannelSftp c = null;
  
  try {
   ftpSession = getFtpSession();
   if (!ftpSession.isConnected()) {
    ftpSession.connect();
   }
   channel = ftpSession.openChannel("sftp");
   InputStream in = channel.getInputStream();
   channel.connect();
   InputStream err_in = channel.getExtInputStream();
   c = (ChannelSftp) channel;
   c.cd("/root");
   
   File fTrans = new File("testJsch.sh");
   storageLoc = "D:\\Jsch\\testJsch.sh"
   File fDest = new File(storageLoc);
   c.get(fTrans.getName(), new FileOutputStream(storageLoc));
 
   byte[] tmp = new byte[1024];
  
   while (true) {
    while (in.available() > 0) {
     int i = in.read(tmp, 0, 1024);
     if (i < 0)
      break;
     String stdOut = new String(tmp, 0, i);
   }
 
   while (err_in.available() > 0) {
    int i = err_in.read(tmp, 0, 1024);
    if (i < 0)
     break;
    String stdErr = new String(tmp, 0, i);
   }
 
   if (channel.isClosed()) {
    break;
   }
  }
   System.out.println("File Transferred: Disconnecting channel and
sessions");
   // Disconnect from the FTP server
   c.quit();
   channel.disconnect();
   ftpSession.disconnect();
 
 
The file is getting transferred to my local system but the control is
struck at read. I can' see the sessions being disconnected.
Please advise.
 
Regards,
P.V.R.Kartik
 

________________________________

From: Keith Alan Richardson [mailto:[email protected]] 
Sent: Wednesday, November 17, 2010 7:37 PM
To: Kartik Pullabhotla v r (WT01 - GMT-Telecom Equipment)
Cc: [email protected]
Subject: Re: RE: FW: [JSch-users] Oracle exp command with jsch



You must read from both of the execChannel's output streams or you risk
deadlock

I can't help out with sftp without seeing your code

        On 17 Nov 2010 15:49, <[email protected]> wrote:
        
        
        Hi,
        
        I have few more doubts regarding this:
        
        I am reading only the error stream but not the output stream (
for the channelExec) and still its working fine. So is it mandatory that
I have to read both the streams every time?
        What about sftp in jsch? Because I think iam facing the same
problem related to sftp. The file is properly transferred but the same
reading method (which worked properly for exec channel) isn't working
here!..what am I missing?
        

        
        Please advise.
        
        Regards,
        P.V.R.Kartik
        
        On Wed, Nov 17, 2010 at 1:32 PM, <kartik.pullabho...@wipro....

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to