コード例 #1
0
        public void Init(SSHParam inparam, STRule inrule, string innodename)
        {
            sshParam = inparam;
            string filepathname = string.Format("/tmp/{0}{1}{2}", innodename, DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss"), inrule.rFileName);

            inrule.rFileName = filepathname;
            STTask task = new STTask();

            task.myRule = inrule;
            task.hName  = innodename;
            task.GetCmdLine();
            myTask = task;
            try {
                sshclient = new SshClient(sshParam.hostIP, sshParam.userName, sshParam.userPWD);
                if (sshclient == null)
                {
                    return;
                }
                sshclient.Connect();
                sshcmd     = sshclient.CreateCommand(task.GetCmdLine());
                ssharesult = sshcmd.BeginExecute();
            } catch (Exception exc) {
                exc.ToString();
            }
        }
コード例 #2
0
 public SSHManager(SSHParam inparam, TextBox intb, RichTextBox inrtb)
 {
     param  = inparam;
     tb     = intb;
     rtb    = inrtb;
     runner = new SSHWrapper();
     myJob  = new STJob();
 }
コード例 #3
0
        public NonBlockFileSession(string inHost, string inUserName, string inPwd, string inCmd, string inOP, string infilename, string innodename)
        {
            SSHParam para = new SSHParam(inHost, inUserName, inPwd);
            STRule   rule = new STRule();

            rule.rCmdLine    = inCmd;
            rule.rFileOption = inOP;
            rule.rFileName   = infilename;
            rule.rType       = STRuleType.NonBlockFile;
            rule.rName       = "NonBlockFileSession internal";
            Init(para, rule, innodename);
        }
コード例 #4
0
        public string BlockExecute(SSHParam inparam, string inCmd)
        {
            string lOutput = string.Empty;

            try {
                using (var client = new SshClient(inparam.hostIP, inparam.userName, inparam.userPWD)) {
                    client.Connect();
                    SshCommand cmd = client.CreateCommand(inCmd);
                    lOutput = cmd.Execute().TrimEnd();
                }
            } catch (Exception exc) {
                _Error += "ExecuteCmdOnSSHServer failed " + exc.Message + Environment.NewLine;
            }
            return(lOutput);
        }