?
Solved

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

Posted on 2001-08-03
6
Medium Priority
?
226 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 600 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

770 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