Is ther any option in telnet that allows me executing the comands after
conecting?
: Is ther any option in telnet that allows me executing the comands after
: conecting?
man rsh
man expect
--
Tim Hockin
tho...@ais.net
tho...@isunix.it.ilstu.edu
This program has been brought to you by the language C and the number F.
From: f...@watsun.cc.columbia.edu (Frank da Cruz)
Newsgroups: comp.unix.programmer
Subject: Re: Telnet
Date: 10 Mar 2000 23:45:27 GMT
Organization: Columbia University
Lines: 75
In article <38C94BFB...@gcg.com>, Chuck Dillon <dil...@gcg.com> wrote:
: ...
: Another poster already mention this but since you don't know
: perl now C I'm guessing a vague reference to 'expect' might
: not stick in your mind.
:
: Expect is a scripting tool that is designed to automated command
: line interactions via pseudo-terminals. It should be exactly
: what you are looking for. Take a look at http://expect.nist.gov.
:
Expect will normally do the job, but it's not available for as many
UNIX platforms as C-Kermit, let alone non-UNIX platforms like VMS,
OS-9, VOS, etc.
Also there is an intrinsic weakness in the 'expect' approach -- all
that 'expect' sees is text. So when automating interactions with some
other program such as telnet or ftp, the only way to tell whether a
particular command succeeded or failed is by parsing the response --
which is notoriously unreliable. In the case of Telnet, it has no
way of knowing if the text it's looking at is from the remote host
or from the local Telnet program. It's just a stream of text.
When the scripting language is intrinsic to the Telnet client, it
knows when a command succeeds or fails because it executed the command
itself. When using 'expect' to drive the Telnet program, you have
to account for various responses:
$ telnet foo.blah <-- Bad hostname
foo.blah: unknown host
telnet>
$ telnet pc.xyzcorp.com <-- Host with no telnet server
Trying 123.123.123.123
telnet: connect: Connection refused
telnet>
$ telnet down.xyzcorp.com <-- Host is down
Trying 123.123.123.124 ...
telnet: connect: Connection timed out
telnet>
$ telnet mainframe.xyzcorp.com <-- Incompatible telnet server
Trying 123.123.123.125 ...
Connected to mainframe.xyzcorp.com
Escape character is '^]'.
Connection closed by foreign host.
$ telnet okhost.com <-- This one worked
Welcome to okhost.com, blah blah ...
login:
And so on...
In C-Kermit, this is programmed as follows:
set host <hostname> /telnet
if fail (take-desired-action) <-- It doesn't matter what the message is.
input 10 login:
if fail ...
Once the connection is made, of course, you still have to script the remote
prompts, commands, and responses. Unless, of course, a Kermit server is
available on the remote system, in which case you can use client/server
commands for most common tasks (including file transfer) and skip the
scripting altogether.
C-Kermit is at:
http://www.columbia.edu/kermit/ckermit.html
Sample telnet and other scripts are at:
http://www.columbia.edu/kermit/ckscripts.html
- Frank
(end quote)