Solved

Connect to a Unix server from VB and automate the login process

Posted on 2001-08-03
6
219 Views
Last Modified: 2013-11-13
I have a VB front end that pulls all my IP addresses for different switches into a text box. My goal is to click a button and get a telnet session open to the IP address in my text box....but due to security issues, I need to telnet into our NMS server(UNIX) before I can telnet to a particular switch. Is there a way to automate the login process to my unix server and then run the telnet command to the IP address in my Text box ? Here is how I am opening a telnet session to my Server..

sub command1_click()
shell "telnet " & IP, vbnormalfocus
end sub

Any help is appreciated....
0
Comment
Question by:sgottipati
6 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 6349248
Use the Winsock control, you can setup a connection to port 23 (telnet) and watch for the login/password strings sent by the unix server. When these are received, simply transmit back the appropriate credentials and it is done. You can then shell the telnet session for the switch so that it can run interactively.
0
 
LVL 1

Accepted Solution

by:
Dean_Reedy earned 150 total points
ID: 6349414
Here is some code I use to connect to a unix server via VB.
This is code from a simple form of mine.  You need to setup the formup, add a winsock control and add textboxes for display and the entering the required information: txtPort,txtHostName,txtPassword,txtUser,txtCommand,txtDisplay, Command1(is the disconnect), cmdRun(connect to server)I think that is all of the boxes.



Private Sub cmdRun_Click()

    WinSock1.Close
    WinSock1.RemotePort = txtPort.text
    WinSock1.RemoteHost = txtHostName.text
    WinSock1.Connect
End Sub

Private Sub sendData(rsData As String, Optional rsUserId As String, Optional rsPwd As String)
Dim lRet As Long
    WinSock1.sendData (Chr(0))
   
    If Not IsMissing(rsUserId) Then
        WinSock1.sendData rsUserId & Chr(0)
    End If
   
    If Not IsMissing(rsPwd) Then
        WinSock1.sendData rsPwd & Chr(0)
    End If
   
    WinSock1.sendData rsData & Chr(0)
   
End Sub


Private Sub Command1_Click()
WinSock1.Close
End Sub

Private Sub Winsock1_Connect()
    txtResults = ""
    sendData txtCommand.Text, txtUser.Text, txtPassword.Text
   
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim sData As String
    WinSock1.GetData sData, vbString
    txtDisplay.Text = txtDisplay.Text & vbCrLf & sData
    If InStr(1, sData, "Process Completed") <> 0 Then
        mbProcessing = False
        DoEvents
        tmrShutDown.Interval = 5000
    End If
End Sub

Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    MsgBox Description, vbInformation, "reporting communication error"
End Sub


Let me know how it goes.

Dean-Iowa
0
 

Author Comment

by:sgottipati
ID: 6350066
Thank you Dean..Is there a simpler way to accomplish the task just by implementing the Shell command to Telnet ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:sgottipati
ID: 6350071
Looking for a Simpler way to accomplish the task..
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7198471
Hi sgottipati,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Dean_Reedy's comment(s) as an answer.

sgottipati, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7213234
Per recommendation, force-accepted.

Netminder
CS Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
delphi parse string to params 3 97
Access query that references subform 5 43
Exit a vb6 apps when a calling it apps closes 15 42
Re-position the objects 7 96
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

911 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

20 Experts available now in Live!

Get 1:1 Help Now