using raw telnet

I’m trying to build a very simple telnet client that allows me to run a
program on the server and collect its output.

I’ve opened the socket and am connecting.

I’m able to send and receive from the socket but its not returning what
I’m expecting. Can someone point me in the right direction where I can
find the protocol for telnet communications. I want to do the following:

logon
run two programs from the command line
collect the output
logoff

Doug Rixmann <rixmannd@rdsdata.com> wrote:

I’m trying to build a very simple telnet client that allows me to run a
program on the server and collect its output.

I’ve opened the socket and am connecting.

I’m able to send and receive from the socket but its not returning what
I’m expecting. Can someone point me in the right direction where I can
find the protocol for telnet communications. I want to do the following:

logon
run two programs from the command line
collect the output
logoff

This is just a suggestion, but I’ve avoided this completely by using
“expect” (it’s available as part of the DejaGNU package on quics).
The idea is that you write a simple script, like “send this”, and
“expect this”, including logging. I’ve used it, for example, to snarf
the active files from nntp sites…

YMMV :slight_smile:

Cheers,
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Consulting and Training at www.parse.com
Email my initials at parse dot com.

In article <9vdh60$pj$1@inn.qnx.com>, “Doug Rixmann”
<rixmannd@rdsdata.com> wrote:

That was one method that I’m trying, the other is as follows:

I’ve created a server application that listens for the request and sends
back the response. This is working (port 15000) and I get the proper
response. Now I’m trying to have it work like telnetd or ftpd so that
when the request comes in on the port, the server is automatically
started.

In /etc/services file I have added the entry:
my_server 15000/tcp

and in the inetd file I have the following:
my_server stream tcp nowait root /bin/my_server

When I run the client, I get a “execv: No such file or directory”

Any thoughts?



I’m trying to build a very simple telnet client that allows me to run a
program on the server and collect its output.

I’ve opened the socket and am connecting.

I’m able to send and receive from the socket but its not returning what
I’m expecting. Can someone point me in the right direction where I can
find the protocol for telnet communications. I want to do the following:

logon
run two programs from the command line collect the output
logoff

“Doug Rixmann” <rixmannd@rdsdata.com> wrote in message
news:9vdo1g$5bp$1@inn.qnx.com

In article <9vdh60$pj$> 1@inn.qnx.com> >, “Doug Rixmann”
rixmannd@rdsdata.com> > wrote:

That was one method that I’m trying, the other is as follows:

I’ve created a server application that listens for the request and sends
back the response. This is working (port 15000) and I get the proper
response. Now I’m trying to have it work like telnetd or ftpd so that
when the request comes in on the port, the server is automatically
started.

In /etc/services file I have added the entry:
my_server 15000/tcp

and in the inetd file I have the following:
my_server stream tcp nowait root /bin/my_server

When I run the client, I get a “execv: No such file or directory”

Any thoughts?

  1. is my_server application located in /bin ?
  2. anyway it should be started smth like this:

my_server stream tcp nowait root /bin/my_server my_server [some other
arguments if required]

…just in order to make argv[0] in main() of your my_server to be equal to
“my_server”.
kind of ftpd does:

ftp stream tcp nowait root /usr/ucb/ftpd in.ftpd -l -d

// wbr

Here is an approach that might be simpler:

  1. login using telent with -a automatic login option
  2. in /etc/passwd, set intial program for this userid to run a shell script
  3. in shell script, run your two local programs putting results in file(s)
  4. in shell script, run ftp with interactive login off (-i) from a script to
    get back results
  5. in shell script, logout

Doug Rixmann wrote:

I’m trying to build a very simple telnet client that allows me to run a
program on the server and collect its output.

I’ve opened the socket and am connecting.

I’m able to send and receive from the socket but its not returning what
I’m expecting. Can someone point me in the right direction where I can
find the protocol for telnet communications. I want to do the following:

logon
run two programs from the command line
collect the output
logoff