Hi I have the below code,
I am able to open putty session but i was not able to give the inputs using C# , i have tried using process.StandardInput.WriteLine
but it is not working . Please help me.
class Program
{
static void Main(string[] args)
{
Process process = new Process();
process.StartInfo.FileName = @"C:\Users\win7\Desktop\putty.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.Arguments = "-ssh mahi@192.168.37.129 22 -pw mahi";
process.Start();
process.StandardInput.WriteLine("ls");
}
}
Hi All , I Have used Plink instead of putty by the suggestion given by Onots.
I have done the following
1.Edited my path in environment variable to my plink location i.e., D:\Plink\
2.Manually Opened Command Prompt and Logged into my host server using plink using the command plink-0.57.exe -ssh mahi@192.168.37.129 -pw mahi and i am able to execute commands manually.
3.Now i have modified the code as below
class Program
{
static void Main(string[] args)
{
Process process = new Process();
process.StartInfo.FileName = @"D:\Plink0.57\plink-057.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.Arguments = " -ssh mahi@192.168.37.129 -pw mahi";
process.Start();
process.StandardInput.WriteLine("ls");
}
}
But i was not able to open plink and the command is not executing using C#. But what happens is , a command prompt just appears and closes immediately , i have figured the error message as
"Unable to write to standard input"
Please help me ,i am not able to proceed any further. Thanks In Advance.