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文件?
我喜歡它!,不需要在我的代碼只是我的巴赫文件改變什麼 –