cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Telnet scripting with PHP

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 22 Feb 2002 13:28:51 +0100 (MET)

On Fri, 22 Feb 2002, Per Auberg wrote:

> Anyone tried to make telnet execute telnet commands ?

Well, I have. Sort of. (*surprise*)

> I dream of setting up a scripting engine against our many routers, saving
> the extremely boring tasks of logging in 30 times a day and writing the
> same commands in every router.
>
> Any experience anyone ???

Yes and no. I don't have any PHP experiences, but I do have a general idea
of it and I know how the telnet parts of libcurl work.

I'll rant a little here to provide a more complete picture of the whole
issue:

TELNET differs from the other protocols in the curl family of supported
protocols: both sides can send data pretty much at any given moment.

libcurl has not been properly designed (or adjusted) to handle protocols like
this. I've repeatedly tried to stress this point when people talk about
TELNET in curl, in the hope that one day someone will say "okay, but then *I*
will make it work better". Usually, this kind of talk just scares people
away! :-/

The libcurl TELNET support will read data on *stdin* and pass to the remote
peer, while it will pass incoming network data to the usual internal mumbo
jumbo.

So, to automate telnet with curl, you need:
 - set telnet options (if you have any special ideas)
 - make a connection to the remote host with 'telnet://hostname'

Then you'll get the data the host sends you the "normal" way, while you need
to somehow pass data to stdin to get them over to the other side.

I hope you this was informative enough.

I am not a PHP hacker.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-02-22