Solved

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

Posted on 2001-08-03
6
217 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you Dean..Is there a simpler way to accomplish the task just by implementing the Shell command to Telnet ?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

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

Expert Comment

by:DanRollins
Comment Utility
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
Comment Utility
Per recommendation, force-accepted.

Netminder
CS Moderator
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 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

16 Experts available now in Live!

Get 1:1 Help Now