0

I am creating a utility in Windows with C# as a programming langugage.

Reqirement is

  1. to create a connection with Unix Server -- i am trying to connect to Putty.exe
  2. delete old files from specific location
  3. copy new files to specific location.

Now, my question is how to pass "host name" + loginID & password to the putty dynamically.

     Process.Start(@"C:\Putty\putty.exe");

This is opening putty with configuration wizard, can i pass all the values in the command directly

Code's
  • 208
  • 2
  • 18
  • try putty.exe -ssh user@host -pw yourpassword – qwr Nov 06 '14 at 05:16
  • When i am passing like Process.Start(@"C:\Putty\putty.exe", -ssh user@host -mypassword); its throwing error – Code's Nov 06 '14 at 06:07
  • [what error?](http://stackoverflow.com/questions/26772059/sending-host-name-login-id-password-dynamically-to-putty-using-c-sharp?noredirect=1#comment42125065_26772059) – qwr Nov 06 '14 at 06:19
  • [check this ready example using plink](http://stackoverflow.com/questions/22028592/testing-using-plink-exe-to-connect-to-ssh-in-c-sharp) – qwr Nov 06 '14 at 06:30

1 Answers1

1

Look into Putty's command line arguments here to pass that to Putty :

string hostname = "hostname";
string login = "login";
string password = "password";


ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Putty\putty.exe";
startInfo.Arguments = string.Format("{0}@{1} -pw {2}",login,hostname, password);
Process process = new Process();
process.StartInfo = startInfo;
process.Start();

Something like that should work...

Tyress
  • 3,573
  • 2
  • 22
  • 45
  • can you also help me to delete the files from certain location once i logged in to putty. Say i have to delete all the files under Folder name NewFolder – Code's Nov 06 '14 at 06:38
  • Sounds like another question @Coder2014. You'd best make a new one if you really can't figure it out. – Tyress Nov 06 '14 at 06:42
  • i have added in the requirement [second point] :) if you can help!! – Code's Nov 06 '14 at 06:44
  • Added new question http://stackoverflow.com/questions/26773567/putty-delete-files-dynamically-using-c-sharp – Code's Nov 06 '14 at 07:07