Solved

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

Posted on 2001-08-03
6
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
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…

688 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