Rex,
this is a method I once used to execute shell commands on a unix machine.
look at the structure and I think you can start from there.
this method is old so it might not be 'elegant' or 'clean' so put those
things aside.
<Code>
public bool Exec(string Command, string Host, int Port,string UN, string
PWD)
{
TcpClient client = null;
byte[] read = new byte[128];
byte[] send = new byte[128];
int bytes;
string data;
try
{
client = new TcpClient(Host,Port);
}
catch (Exception ex) //connection problem
{
throw ex;
}
NetworkStream stream = client.GetStream();
send = Encoding.ASCII.GetBytes(UN);
stream.Write(send,0,send.Length);
bytes = stream.Read(read, 0, read.Length);
data = Encoding.ASCII.GetString(read);
send = Encoding.ASCII.GetBytes(PWD);
stream.Write(send,0,send.Length);
bytes = stream.Read(read, 0, read.Length);
data = Encoding.ASCII.GetString(read);
send = Encoding.ASCII.GetBytes(Command);
stream.Write(send,0,send.Length);
bytes = stream.Read(read, 0, read.Length);
string retval = Encoding.ASCII.GetString(read);
stream.Close();
client.Close();
if (retval[0]=='0')
return true;
else
return false;
}
</Code>
Picho
"Rex Winn" <re*@code-frog.com> wrote in message
news:15**********************@msnews.microsoft.com ...
I've Googled until my eyes hurt looking for a way to issue Telnet
commands from C# and cannot find anything but $300 libraries
that encapsulate it for you. I don't want to be able to create a
Telnet client. I just need to send a telnet request to a local IP
address on a LAN issue a "c" then a "b" and stream back the
text for internal use. The "c" changes sub-menus and the "b" is
a switch to dump the status of a firewall. I need to issue the
"b" every second and capture that stream of text that would
go to a telnet client and use it internally. Is there a way that
C# can do this programmatically? System.Diagnostices.Process
is not the solution that I am aware of. Maybe there's a switch
for it to hide the telnet window and wrap it but I couldn't find
anything to support that.
- Rex