1

I am using a switch and I want to connect it via ssh or telnet and send commands to specific ports. I succeeded connecting to the switch but I am not able to execute commands after login.

string command = "reboot";
using (Process process = new Process())
{
     process.StartInfo.FileName = "plink.exe";
     process.StartInfo.Arguments = "[email protected] -pw admin " + command;
     process.StartInfo.UseShellExecute = true;
     process.StartInfo.CreateNoWindow = false;
     process.Start();
}

Code given above logins to the switch interface but not execute the command. It hangs with switch# text.

I tried a couple of things from cmd and I am able to get command on the screen after login but now I cannot get the same result when I write same text in C# code.

plink.exe [email protected] -pw admin < D:\input.txt --> this works when executed from cmd not in C#.

using (Process process = new Process())
{
     process.StartInfo.FileName = "plink.exe";
     process.StartInfo.Arguments = "[email protected] -pw admin < D:\\input.txt";
     process.StartInfo.UseShellExecute = true;
     process.StartInfo.CreateNoWindow = false;
     process.Start();
}

What could be the reason? Thanks

snvngrc
  • 177
  • 2
  • 4
  • 12

0 Answers0