Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 818
  • Last Modified:

HOW TO CALL UNIX SHELL SCRIPT FROM VB.NET 2005 APPLICATION

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", "$")
            Else
                Console.WriteLine("Username prompt was not found")
            End If
        Else
            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

0
nemesis7
Asked:
nemesis7
  • 2
1 Solution
 
mankowitzCommented:
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.
0
 
mankowitzCommented:
0
 
nemesis7Author Commented:
Can you please post the exact solution here, too much digging up to do in there. Thanks
0
 
ahoffmannCommented:
> .. 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.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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