0

Hello I am conneted to an Unix server by sharpssh with :

Imports Tamir.SharpSsh
Imports Tamir.Streams

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


        Dim ssh As SshExec
        ssh = New SshExec("********", "******", "*****")
        ssh.Connect()
        ssh.RunCommand("amos RNC111")
        ssh.RunCommand("lt all")
        ssh.RunCommand("bye")
        ssh.Close()

    End Sub
End Class

The issue is after ssh.Connect() I have to connect to a RNC(Radio network controller) and wait until it is connected. I dont know how to handle it, I check to do it with redirecction the stdin but I found to create a new process with :

    myProcess.StartInfo.FileName = "pepe.exe"
    myProcess.StartInfo.UseShellExecute = False
    myProcess.StartInfo.RedirectStandardInput = True
    myProcess.Start()
    Dim ssh As SshExec
    ssh = New SshExec("********", "******", "*****")
    ssh.Connect()
    ssh.RunCommand("amos RNC111")
    MsgBox(myProcess.StandardInput)
    ssh.Close()

But I is not working.

1 Answers1

0

You can use the SshShell class inside the Tamir Assemblies and use the Expect pattern:

string pattern="admin@localhost:~$";
string res = string.Empty;
myshell2 = new Tamir.SharpSsh.SshShell(ipaddress, cteUser, ctePasswd);
myshell2.ExpectPattern = pattern;
myshell2.RemoveTerminalEmulationCharacters = true;
myshell2.Connect();

//Launch command

myshell2.WriteLine("ls -la");
res = myshell2.Expect(pattern);

The shell will wait until that terminal line is found.

Carlos Landeras
  • 11,025
  • 11
  • 56
  • 82