473,379 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

VB2005 : Send input to a TELNET process - IP/User/Password/Sign-on

Hi,

I looked and found a lot of different code regarding send/receiving
input/output to a command window, but none helped me so far.

I would like to start a process with telnet a bit like this
myProcess.StartInfo.FileName = "telnet.exe"
myProcess.StartInfo.Arguments = " -a 199.99.99.99 299" ' (IP and port) =
this works....

then wait for the process to be ready

to send the user + wait

to send the password + wait

to send the sign-on option and quit the process

I didn't find anything that was useful to help me.

I found code with streamreaders and streamwriters and redirecting input and
output,

problem is I don't have a cmd window anymore and I don't see anything
happening, also it's not working because the connection fails...
--
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------
Oct 15 '07 #1
2 6776
Hi,

System.Net.Sockets.TcpClient is the class name.

You would open a TCP/IP socket (the TcpClient) using the telnet server
Address and Port(typically, port 23, but some servers may use another port
number) as a stream

You then set a TextWriter to use the stream just opened and write your
output using the TextWriter Write method. You can use Thread.Sleep to add a
delay after the Write.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Oct 15 '07 #2


--
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------
"Dick Grier" <dick_grierNOSPAM@.msn.comschreef in bericht
news:uh**************@TK2MSFTNGP04.phx.gbl...
Hi,

System.Net.Sockets.TcpClient is the class name.

You would open a TCP/IP socket (the TcpClient) using the telnet server
Address and Port(typically, port 23, but some servers may use another port
number) as a stream

You then set a TextWriter to use the stream just opened and write your
output using the TextWriter Write method. You can use Thread.Sleep to add
a delay after the Write.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.

OK thanks, I looked up things in that direction,
and I found something useful, which seems to work.

Imports System.Net.Sockets

Imports System.Text

Public Class Form1

Private oTCPStream As Net.Sockets.NetworkStream

Private oTCP As New Net.Sockets.TcpClient()

Private bytWriting As [Byte]()

Private bytReading As Byte()

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Try

TextBox1.Text = ""

oTCP.SendTimeout = 1500

oTCP.Connect("999.99.99.9", "259")

oTCPStream = oTCP.GetStream

TextBox1.Text = TextBox1.Text & ReadData() & vbCrLf

WriteData("myusername" & vbCrLf)

System.Threading.Thread.Sleep(500)

TextBox1.Text = TextBox1.Text & ReadData() & vbCrLf

WriteData("mypassword" & vbCrLf)

System.Threading.Thread.Sleep(1000)

TextBox1.Text = TextBox1.Text & ReadData() & vbCrLf

WriteData("1" & vbCrLf)

TextBox1.Text = TextBox1.Text & ReadData() & vbCrLf

oTCPStream.Close()

oTCP.Close()

MsgBox("connection ok")

Catch Err As Exception

MsgBox(Err.ToString)

End Try

End Sub

Private Function ReadData() As String

Dim sData As String

ReDim bytReading(oTCP.ReceiveBufferSize)

oTCPStream.Read(bytReading, 0, oTCP.ReceiveBufferSize)

sData = Trim(System.Text.Encoding.ASCII.GetString(bytReadi ng))

ReadData = sData

End Function

Private Sub WriteData(ByVal sData As String)

bytWriting = System.Text.Encoding.ASCII.GetBytes(sData)

oTCPStream.Write(bytWriting, 0, bytWriting.Length)

End Sub
Oct 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: G520 | last post by:
Hi I have been getting statistical rapports from a machine via a telnet server. Until now it has been done manually. However I want to automate the proccess, and scedule a PHP script to run...
6
by: Jinming Xu | last post by:
Hello Everyone, I am trying to write a python script to telnet to a server and then do something there. As the first step, I practiced the python example in Lib Reference 11.13.2. But I am...
2
by: john brown | last post by:
I'm telnetting into a router. Apart from the fact I can't seem to view the output when iniciating the session, I can't match one of the expressions using Net::Telnet. I can telnet into the router...
1
by: malborg | last post by:
I have simple form in PHP with two input types as text to input login name and password.PS: They use POST method. (index.php) The other script(logowanie.php) checks if login and password is...
3
by: Horst Walter | last post by:
What I try to accomplish is to run "telnet.exe" as a process in C#. The C#-code below works with terminating commands, e.g. a "HelloWorld.exe". Since I'd like to communicate with "telnet" the...
1
by: ZackSnr | last post by:
I am in the process of moving from VB6 to VB2005. I need some help with methods that I frequently use in my apps and are struggling to find the equivalent process and more sepcifically code examples...
2
by: RYAN1214 | last post by:
How can I use this random password code, and then insert the password into email which is sent to the user after the registration has been finished? thx <html> <head> <title>Javascript:...
1
by: thamayanthi | last post by:
Hi, Please find the below code which is used to Print the Operating System of a remote Machine of linux.This code is working fine,if i give the correct UserName and Password of a machine but what...
2
by: thamayanthi | last post by:
Hi, The below code is used to connect to the remote machine using Telnet module in perl. use Net::Telnet; use Net::Ping; $telnet = new Net::Telnet (Timeout=>10,Errmode=>'die'); open...
17
by: ravimath | last post by:
Dear all, I have written following script to loin to router bu it is showing error. #!c:\Perl\bin; use strict; use warnings; my $hostname = 'REMOVED FOR YOUR PROTECTION'; my $password =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.