Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pipe & telnet

150 views
Skip to first unread message

al1...@my-deja.com

unread,
Jan 3, 2000, 3:00:00 AM1/3/00
to
Hi

I would like to execute something like 'cat foo | telnet host port'
where foo is a regular file.

I've also tried something like 'telnet host port < foo' with nore more
success.

each time, telnet claims that the connection is closed by the foreign
host. and i know the command has not been performed on the remote
server.

i'm sure i did not use pipes properly...

note : i'm using tcsh.

any help?

thanks a lot.

Sent via Deja.com http://www.deja.com/
Before you buy.

st...@peachy.com

unread,
Jan 3, 2000, 3:00:00 AM1/3/00
to al1...@my-deja.com
Telnet is acting too fast. See below : the first method fails, but by
adding a sleep in the second method, works okay.

Steve
st...@peachy.com

sysadm@mybox> echo quit | telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

sysadm@mybox> ( sleep 1 ; echo quit ) | telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mybox ESMTP Sendmail 8.8.8+Sun/SMI-SVR4 ready at Mon, 3 Jan 2000
12:04:23 GMT
Connection closed by foreign host.

In article <84q012$mo$1...@nnrp1.deja.com>,

Kevin Wilson

unread,
Jan 3, 2000, 3:00:00 AM1/3/00
to
On Mon, 03 Jan 2000 11:09:26 GMT, al1...@my-deja.com <al1...@my-deja.com> wrote:

> I would like to execute something like 'cat foo | telnet host port'
> where foo is a regular file. I've also tried something like 'telnet
> host port < foo' with nore more success. each time, telnet claims
> that the connection is closed by the foreign host. and i know the
> command has not been performed on the remote server. i'm sure i did
> not use pipes properly... note : i'm using tcsh.

Try using `netcat'. That should be what you need. Also Perl can deal
with things like that.

--
"Who needs more than 640k? We do, Bill."
http://www.linux.org/

Kevin Wilson, Imperial College, London. [Please do not reply via e-mail]
-------

Chris

unread,
Jan 3, 2000, 3:00:00 AM1/3/00
to

What are you trying to do? Are you trying to pass files between two
machines? netcat works pretty much like telnet, if i remember
correctly, but will keep the port open, unlike telnet, after EOF. But you
talk about remote command too so maybe a remote shell is what you're
looking for.
man rsh
man rcmd

Chris


PEZ

unread,
Jan 3, 2000, 3:00:00 AM1/3/00
to
In article <84q012$mo$1...@nnrp1.deja.com>,

al1...@my-deja.com wrote:
> I would like to execute something like 'cat foo | telnet host port'
> where foo is a regular file.

DING! Don't do that. (cat foo |). Read:
http://www.ling.helsinki.fi/users/reriksso/unix/award.html

> I've also tried something like 'telnet host port < foo' with nore
more
> success.

That's more like it.

> each time, telnet claims that the connection is closed by the foreign
> host. and i know the command has not been performed on the remote
> server.

Someone already suggested rsh. But I think that requires user/host
equivalence. If you don't have that you might be helped by "expect". A
tool with which you can spawn sessions and feed them with commands.
(well, you can do much more than that). The expect distribution comes
with a command called autoexpect that works somewhat like the "script"
command. You can record interactive sessions and get the expect script
that would repeat what you just did. You can massage that script to
feed the other host with those command you have in your foo file.

FWIW,
/Peter
--
-= Spam safe(?) e-mail address: pez68 at netscape.net =-

al1...@my-deja.com

unread,
Jan 4, 2000, 3:00:00 AM1/4/00
to

thanks a lot for your help.

i didn't want to perform commands on a remote host but simply do
something like this :

telnet www.foo.com 80 < foo

where foo is regular file containing "get /foo.html\n\r\n\r" :-)

but it doesn't work this way.

netcat seems to be exactly what i need. i'll try it.

OldUncleMe

unread,
Jan 4, 2000, 3:00:00 AM1/4/00
to
It was: Tue, 04 Jan 2000 00:16:48 GMT and with STARTLING insight,
"al1...@my-deja.com"
posted "Re: pipe & telnet"
to "comp.unix.shell" :

-->
-->
-->thanks a lot for your help.
-->
-->i didn't want to perform commands on a remote host but simply do
-->something like this :
-->
-->telnet www.foo.com 80 < foo
-->
-->where foo is regular file containing "get /foo.html\n\r\n\r" :-)
-->
-->but it doesn't work this way.
-->
-->netcat seems to be exactly what i need. i'll try it.

Telnet is a program basically for emulating the command line interface on a
remote machine to the local screen. It's really not useful for file
transfers. Ftp is the basic place you would start, as it's a file transfer
utility. When you use the 'get' command in your example above you are
using a standard ftp command; telnet doesn't include 'get' as a command.
There are other utils besides ftp for remote file transfer across networks.


Good luck, /ts

tenox @ home dot com

Ken Pizzini

unread,
Jan 4, 2000, 3:00:00 AM1/4/00
to
On Tue, 04 Jan 2000 16:57:21 GMT, OldUncleMe <NoLo...@ix.netcom.com> wrote:
>-->telnet www.foo.com 80 < foo
>-->
>-->where foo is regular file containing "get /foo.html\n\r\n\r" :-)

>Telnet is a program basically for emulating the command line interface on a


>remote machine to the local screen. It's really not useful for file
>transfers. Ftp is the basic place you would start, as it's a file transfer
>utility. When you use the 'get' command in your example above you are
>using a standard ftp command; telnet doesn't include 'get' as a command.
>There are other utils besides ftp for remote file transfer across networks.

Well, that looks a lot more like a http transfer than a ftp
transfer, but the advice is still sound --- programs such as
lynx or GNU's "wget" are better suited to this task than is
telnet. While netcat is a very useful program to have, and
can be used effectively for this, it is not the most natural
tool for grabbing a text over http.

--Ken Pizzini

Chris Costello

unread,
Jan 5, 2000, 3:00:00 AM1/5/00
to
Ken Pizzini <k...@halcyon.com> wrote:
> Well, that looks a lot more like a http transfer than a ftp
> transfer, but the advice is still sound --- programs such as
> lynx or GNU's "wget" are better suited to this task than is
> telnet. While netcat is a very useful program to have, and
> can be used effectively for this, it is not the most natural
> tool for grabbing a text over http.

There are also programs like FreeBSD's fetch (and its
`libfetch' library) that handle all sorts of URLs: file, http,
ftp, ...

See http://www.FreeBSD.org/cgi/man.cgi?fetch

- Chris Costello <ch...@FreeBSD.org>

0 new messages