1
我正在编写一个控制台应用程序,它将使用一组指令。C#控制台和.bat指令
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)
{
}
}
我使用会是这个样子
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
当我运行它打开SSHUpdate.exe,我可以使用ARGS连接.bat文件,但我无法批处理文件从相同的进程访问行的其余
所有服务器将使用相同的密码或私人密钥
目前我正在做如下操作 SSHUpdate.exe“SSHPWD”“用户名”“密码”“指令文件”其中指令文件中包含指令
我应该坚持还是有办法我可以获取下一行指令,只需要具有.exe和.bat文件?
我喜欢它!,不需要在我的代码只是我的巴赫文件改变什么 –