title: Execute Unix commands using putty in C#
body: <p>Hi I have the below code,</p>
  
  <p>I am able to open putty session  but i was not able to give the inputs using C# , i have tried using <code>process.StandardInput.WriteLine</code>  but it is not working . Please help me.</p>
  
  <pre><code>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");
  
  
      }
  }
  </code></pre>
  
  <p>Hi All , I Have used Plink instead of putty by the suggestion given by Onots. </p>
  
  <p>I have done the following</p>
  
  <p>1.Edited my path in environment variable to my plink location i.e., D:\Plink\</p>
  
  <p>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.</p>
  
  <p>3.Now i have modified the code as below</p>
  
  <pre><code>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");
      }
  }
  </code></pre>
  
  <p>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 </p>
  
  <pre><code>"Unable to write to standard input"
  </code></pre>
  
  <p>Please help me ,i am not able to proceed any further. Thanks In Advance.</p>