Is it possible to run multiple commands in putty or plink using c#? Currently I'm using below code to run a single command to reached particular folder in my server.
Once I reached that folder I wanted to delete all the files under that folder, but how to write multiple commands using below approach?
Requirement is to run below 2 commands one by one command 1 = CD /Dir1/dir2/NewFolder & command 2 = rm *.txt"
string hostname = "hostname";
string login = "login";
string password = "password";
string command = "CD /Dir1/dir2/NewFolder";
const string scriptFileName = @"remote_commands.sh";
File.WriteAllText(scriptFileName, command);
var startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Putty\putty.exe";
startInfo.Arguments = string.Format("{0}@{1} -pw {2} -m {3}",
login, hostname, password, scriptFileName);
var process = new Process {StartInfo = startInfo};
process.Start();
process.WaitForExit();