Run cmd command and see output in the same cmd

  • Thread starter Thread starter Andrei-Eduard Lica
  • Start date Start date
A

Andrei-Eduard Lica

Guest
I am trying to open a cmd.exe that will connect through ssh to a remote server and there it will run a script that will output some data. I would like to be able to see that data in the same CMD window that I've opened, not in the Visual Studio Console. How can I do that? The code I have so far:

Right now it works, but outputs the ls output into the visual studio console, not in my cmd console. Thank you!


Process process = new Process();
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = "cmd.exe",
RedirectStandardInput = true,
UseShellExecute = false,
Arguments = "/k ssh pi@192.168.1.150"
};


process.StartInfo = psi;
process.Start();
using (System.IO.StreamWriter sw = process.StandardInput)
{

sw.WriteLine("ls".Replace("/r/n", "/n"));
}

process.WaitForExit();

Continue reading...
 
Back
Top