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(); } }
public SSHManager(SSHParam inparam, TextBox intb, RichTextBox inrtb) { param = inparam; tb = intb; rtb = inrtb; runner = new SSHWrapper(); myJob = new STJob(); }
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); }
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); }