/// <exception cref="NGit.Errors.TransportException"></exception>
			internal override void Exec(string commandName)
			{
				this._enclosing.InitSession();
				try
				{
					this.channel = (ChannelExec)this._enclosing.sock.OpenChannel("exec");
					this.channel.SetCommand(this._enclosing.CommandFor(commandName));
				}
				catch (JSchException je)
				{
					throw new TransportException(this._enclosing.uri, je.Message, je);
				}
			}
			internal override void Close()
			{
				if (this.channel != null)
				{
					try
					{
						this.exitStatus = this.channel.GetExitStatus();
						if (this.channel.IsConnected())
						{
							this.channel.Disconnect();
						}
					}
					finally
					{
						this.channel = null;
					}
				}
			}
Exemple #3
0
 /// <summary>
 /// Opens a channel on the session ("sock") for executing the given
 /// command, opens streams, and starts command execution.
 /// </summary>
 /// <remarks>
 /// Opens a channel on the session ("sock") for executing the given
 /// command, opens streams, and starts command execution.
 /// </remarks>
 /// <param name="commandName">the command to execute</param>
 /// <param name="tms">the timeout value, in seconds, for the command.</param>
 /// <exception cref="NGit.Errors.TransportException">
 /// on problems opening a channel or connecting to the remote
 /// host
 /// </exception>
 /// <exception cref="System.IO.IOException">on problems opening streams</exception>
 public JschProcess(JschSession _enclosing, string commandName, int tms)
 {
     this._enclosing = _enclosing;
     this.timeout = tms;
     try
     {
         this.channel = (ChannelExec)this._enclosing.sock.OpenChannel("exec");
         this.channel.SetCommand(commandName);
         this.SetupStreams();
         this.channel.Connect(this.timeout > 0 ? this.timeout * 1000 : 0);
         if (!this.channel.IsConnected())
         {
             throw new TransportException(this._enclosing.uri, "connection failed");
         }
     }
     catch (JSchException e)
     {
         throw new TransportException(this._enclosing.uri, e.Message, e);
     }
 }