static private Process StartPuttyShell(string arguments) { Process process = new Process(); process.StartInfo.FileName = TargetManagerSettings.GetPUTTYFilename(); process.StartInfo.Arguments = arguments; process.Start(); return(process); }
static public bool CopyDirectoryFromTarget(string user, string pw, string ip_addr, string src_filename, string dest_filename) { string arguments = String.Format("-r -l {0} -pw {1} {2}:{3} {4}", user, // 0 pw, // 1 ip_addr, // 2 src_filename, // 3 dest_filename); string outstring, errstring; return(ExecuteToCompletion(TargetManagerSettings.GetPSCPFilename(), arguments, out outstring, out errstring) == 0); }
static public bool CopyFileToTarget(string user, string pw, string ip_addr, string src_filename, string dest_filename) { string arguments = String.Format("-l {0} -pw {1} {2} {3}:{4}", user, pw, src_filename, ip_addr, dest_filename); string outstring, errstring; return(ExecuteToCompletion(TargetManagerSettings.GetPSCPFilename(), arguments, out outstring, out errstring) == 0); }
static public int ShellExecuteToCompletion(string user, string pw, string ip_addr, string remote_filename, out string stdout, out string stderr) { // Algorithm create a 'putty command script' // create a command file, stuff the command to execute in there, then execute it string local_temp_file = System.IO.Path.GetTempFileName(); using (var file = new StreamWriter(local_temp_file)) { file.Write("bash -e " + remote_filename + "\n"); } string arguments = String.Format("-ssh {0}@{1} -pw {2} -m {3} -batch", user, ip_addr, pw, local_temp_file); int result = ExecuteToCompletion(TargetManagerSettings.GetPLINKFilename(), arguments, out stdout, out stderr); System.IO.File.Delete(local_temp_file); return(result); }