Beispiel #1
0
        private ChannelSftp NewSftp()
        {
            InitSession();

            // No timeout support in our JSch
            try
            {
                Channel channel = Sock.openChannel("sftp");
                channel.connect();
                return((ChannelSftp)channel);
            }
            catch (JSchException je)
            {
                throw new TransportException(Uri, je.Message, je);
            }
        }
        private ChannelExec Exec(string exe)
        {
            InitSession();

            try
            {
                var channel = (ChannelExec)Sock.openChannel("exec");
                channel.setCommand(commandFor(exe));
                _errStream = CreateErrorStream();
                channel.setErrStream(_errStream);
                channel.connect();
                return(channel);
            }
            catch (JSchException e)
            {
                throw new TransportException(Uri, e.Message, e);
            }
        }
Beispiel #3
0
        private ChannelExec Exec(string exe)
        {
            InitSession();

            try
            {
                var    channel = (ChannelExec)Sock.openChannel("exec");
                string path    = Uri.Path;
                if (Uri.Scheme != null && Uri.Path.StartsWith("/~"))
                {
                    path = (Uri.Path.Substring(1));
                }

                var cmd      = new StringBuilder();
                int gitspace = exe.IndexOf("git ");
                if (gitspace >= 0)
                {
                    SqMinimal(cmd, exe.Slice(0, gitspace + 3));
                    cmd.Append(' ');
                    SqMinimal(cmd, exe.Substring(gitspace + 4));
                }
                else
                {
                    SqMinimal(cmd, exe);
                }

                cmd.Append(' ');
                SqAlways(cmd, path);
                channel.setCommand(cmd.ToString());
                _errStream = CreateErrorStream();
                channel.setErrStream(_errStream);
                channel.connect();
                return(channel);
            }
            catch (JSchException e)
            {
                throw new TransportException(Uri, e.Message, e);
            }
        }