All wodCrypt (12) wodSSH (10) wodSFTP (23) wodSSHServer (1) wodSSHTunnel (11) wodSSHpackage wodSFTPdll wodSSH.NET (10) wodSFTP.NET (24) wodFtpDLX.NET (22) wodWebServer.NET (10) wodAppUpdate (13) wodHttpDLX (8) wodFtpDLX (22) wodTelnetDLX wodFTPServer (3) wodWebServer (10) wodVPN wodXMPP (13) | All ** [Visual Basic] ** [C#] ** [VB.NET] ** Send multiple commands to SSH server using synchronous connection
VB code
Dim wodSSH1 As wodSSHCom Set wodSSH1 = New wodSSHCom 'Authenticate with server using hostname, login, password. wodSSH1.HostName = "your_hostname" wodSSH1.Login = "your_login" wodSSH1.Password = "yout_password" wodSSH1.Blocking = True 'Use synchronous connections wodSSH1.Connect 'Wait for a prompt. Regular expression is used for a prompt. wodSSH1.WaitFor ("regex:[\$%#>] $") wodSSH1.DataReady = 0 'Empty bytes inside buffer 'Execute command using Execute Method. 'Execute Method will send the command of your choice to the server and wait for it to complete. Debug.Print wodSSH1.Execute("command 1" + vbLf, "regex:[\$%#>] $") wodSSH1.DataReady = 0 Debug.Print wodSSH1.Execute("command 2" + vbLf, "regex:[\$%#>] $") wodSSH1.DataReady = 0 Debug.Print wodSSH1.Execute("command 3" + vbLf, "regex:[\$%#>] $") 'and so on ... wodSSH1.Disconnect 'Disconnect from server VB.NET code
Uses wodSSH.NET component
Dim wodSSH1 As WeOnlyDo.Client.SSH wodSSH1 = New WeOnlyDo.Client.SSH 'Authenticate with server using hostname, login, password. wodSSH1.Hostname = "your_hostname" wodSSH1.Login = "your_login" wodSSH1.Password = "your_password" wodSSH1.Blocking = True 'Use synchronous connections wodSSH1.Connect() 'Wait for a prompt. Regular expression is used for a prompt. wodSSH1.WaitFor("regex:[\$%#>] $") wodSSH1.DataReady = 0 'Empty bytes inside buffer 'Execute command using Execute Method. 'Execute Method will send the command of your choice to the server and wait for it to complete. Console.WriteLine(wodSSH1.Execute("command 1" & vbLf, "regex:[\$%#>] $")) wodSSH1.DataReady = 0 Console.WriteLine(wodSSH1.Execute("command 2" & vbLf, "regex:[\$%#>] $")) wodSSH1.DataReady = 0 Console.WriteLine(wodSSH1.Execute("command 3" & vbLf, "regex:[\$%#>] $")) 'and so on ... wodSSH1.Disconnect() 'Disconnect from server C# code
Uses wodSSH.NET component
WeOnlyDo.Client.SSH wodSSH1; wodSSH1 = new WeOnlyDo.Client.SSH(); //Authenticate with server using hostname, login, password. wodSSH1.Hostname = "your_hostname"; wodSSH1.Login = "your_login"; wodSSH1.Password = "your_password"; wodSSH1.Blocking = true; //Use synchronous connections wodSSH1.Connect(); //Wait for a prompt. Regular expression is used for a prompt. wodSSH1.WaitFor("regex:[\\$%#>] $"); wodSSH1.DataReady = 0; //Empty bytes inside buffer //Execute command using Execute Method. //Execute Method will send the command of your choice to the server and wait for it to complete. Console.Write(wodSSH1.Execute("command 1\n", "regex:[\\$%#>] $")); wodSSH1.DataReady = 0; Console.Write(wodSSH1.Execute("command 2\n", "regex:[\\$%#>] $")); wodSSH1.DataReady = 0; Console.Write(wodSSH1.Execute("command 3\n", "regex:[\\$%#>] $")); //and so on ... wodSSH1.Disconnect(); //Disconnect from server |