Solved

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

Posted on 2001-08-03
6
224 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Technology Partners: 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!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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