I am writing a Console application that will work with a set of instructions.
class Program
{
static void Main(string[] args)
{
var cmd = "";
if (args.Length > 0)
{
cmd = args[0];
}
switch (cmd)
{
case "SSHPPK":
InitPpk(InitCompleted, args); //Read from args
break;
case "SSHPWD":
InitPwd(InitCompleted, args); //Read from args
break;
default:
Console.WriteLine("Invalid Command");
break;
}
}
private static void InitCompleted(ConnectInstructions instructions)
{
//Read next lines from .bat file and execute untill the end (Psuedo, While not at end of file)
//Get command
//Get server IP
if (instructions.ConnectType == "SSHPPK")
{
//Connect using Private Key
}
else if (instructions.ConnectType == "SSHPWD")
{
//Connect using Password
}
//Get Root
//Do update
}
private static void InitPwd(Action<ConnectInstructions> action, string[] args)
{
}
private static void InitPpk(Action<ConnectInstructions> action, string[] args)
{
}
}
The batch file I am using will look something like this
SSHUpdate.exe "SSHPWD" "Username" "Password"
update [Server1 IP] /var/root/site
update [Server2 IP] /var/root/site
update [Server3 IP] /var/root/site
update [Server4 IP] /var/root/siteA
update [Server4 IP] /var/root/siteB
And when I run the .bat file it opens SSHUpdate.exe and I can connect using the args, But I am unable to access the rest of the lines from the same process
All Servers will use the same password or private key
Currently I am doing it like the following SSHUpdate.exe "SSHPWD" "Username" "Password" "Instruction File" where the Instruction File contains the instructions
Should I stick with that or is there a way where I can get the next line of instructions and only need to have the .exe and the .bat files?