/** * Execute the remote command. */ private void remoteExecute() { System.IO.Stream server; System.Diagnostics.Debug.WriteLine("RemoteExecute"); try { channel = session.openChannel("exec"); } catch (Exception e) { throw new ApplicationException("Cannot open channel to host " + remoteHost + ":" + port + " : " + e.ToString()); } ((ChannelExec)channel).setCommand(command); //channel.setInputStream(null); /* * try * { * sIn = channel.getInputStream(); * sOut = channel.getOutputStream(); * } * catch (Exception e) * { * throw new ApplicationException("Cannot get input stream to host " + * remoteHost + ":" + port + " : " + * e.ToString()); * } * */ server = new Tamir.Streams.CombinedStream(channel.getInputStream(), channel.getOutputStream()); try { channel.connect(); } catch (Exception e) { throw new ApplicationException("Cannot execute " + command + "@" + remoteHost + ":" + port + " : " + e.ToString()); } sIn = server; sOut = server; }
/// <summary> /// Connect a channel to the remote server using the 'SCP From' command ('scp -f') /// </summary> /// <param name="channel">Will contain the new connected channel</param> /// <param name="server">Will contaun the new connected server I/O stream</param> /// <param name="rfile">The remote path on the server</param> /// <param name="recursive">Idicate a recursive scp transfer</param> protected void SCP_ConnectFrom(out Channel channel, out Stream server, string rfile, bool recursive) { string scpCommand = "scp -f "; if (recursive) { scpCommand += "-r "; } scpCommand += "\"" + rfile + "\""; channel = (ChannelExec)m_session.openChannel(ChannelType); ((ChannelExec)channel).setCommand(scpCommand); server = new Tamir.Streams.CombinedStream (channel.getInputStream(), channel.getOutputStream()); channel.connect(); //SCP_CheckAck(server); }
/// <summary> /// Connect a channel to the remote server using the 'SCP From' command ('scp -f') /// </summary> /// <param name="channel">Will contain the new connected channel</param> /// <param name="server">Will contaun the new connected server I/O stream</param> /// <param name="rfile">The remote path on the server</param> /// <param name="recursive">Idicate a recursive scp transfer</param> protected void SCP_ConnectFrom(out Channel channel, out Stream server, string rfile, bool recursive) { string scpCommand = "scp -f "; if(recursive) scpCommand += "-r "; scpCommand += "\""+rfile+"\""; channel = (ChannelExec)m_session.openChannel(ChannelType); ((ChannelExec)channel).setCommand(scpCommand); server = new Tamir.Streams.CombinedStream (channel.getInputStream(), channel.getOutputStream()); channel.connect(); //SCP_CheckAck(server); }