• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 822
  • Last Modified:


I need a complete code/function/program that I can use in my VB.Net 2005 program to login into a UNIX box & call a Shell script.
I have a function waitfor(login: ) (where login is the prompt which I will get after telnet). This will wait for login:  on the telnetted machine and then fire some command. But that prompt is not coming. The code that I am using is:

Module Module1
    Sub Main ()
        Dim ip As String = "xx.xx.xx.xx"
        Dim port As Integer = 23
        Dim timeout As Integer = 100

        'create the object supplying the parameters
        Dim session As New ScriptingTelnet(ip, port, timeout)
        Dim connected As Boolean = session.Connect() 'try to connect

        If connected = True Then
         'connected sucessfully
            Dim startingPrompt As Integer = session.WaitFor("login:")
            If startingPrompt = 0 Then
                'the username prompt was found so we send the username
                'and wait to receive our password prompt
                session.SendAndWait("vvvv", "password: ")
                'now send the password and wait for our next prompt
                'in this sample I expect to receive a success message
                session.SendAndWait("vvvv", "$")
                Console.WriteLine("Username prompt was not found")
            End If
            Console.WriteLine("Unable to connect to the server")
        End If
    End Sub
End Module

But whenever I try to login the string that I am getting is ??_??_??#??'??$. I am not getting what is it so cant proceed. Please help!



Above program is a Console Program. Once this is done I can convert it to GUI programming, API anyone can download from the gven path.

Please help me in developing this&&..

if using socket programming I try to do this then how can I? and what all I have to set up on the SERVER side

  • 2
1 Solution
Do you have docs for ScriptingTelnet? Where is ti from?

Sometimes, you have to send a couple of chars for a telnet session to pay attention. Send a CR or two just after you connect.

In the past, I was not able to find a good scripting tool, so I made a rudimentary one myself... Lemme see if I can find it.
nemesis7Author Commented:
Can you please post the exact solution here, too much digging up to do in there. Thanks
> .. But that prompt is not coming.
unix programs never print labels and ask for credentials like passwords on STDOUT/STDIN (for obvious security reason), they always use the tty, hence you have to access the tty or the socket directly.
I'd suggest to use expect http://expect.nist.gov/ instead.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now