Posted on 2007-08-01
Last Modified: 2013-12-16
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

Question by:nemesis7
    LVL 24

    Expert Comment

    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.
    LVL 24

    Expert Comment


    Author Comment

    Can you please post the exact solution here, too much digging up to do in there. Thanks
    LVL 51

    Accepted Solution

    > .. 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 instead.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now