Q: interacting with exec'ed commands ? 
Author Message
 Q: interacting with exec'ed commands ?


I try to write a tcl-script that telnets to some host. The script should open
the telnet connection and then behave like a human i.e. read the output of the
telnet cmd and write commands to it.
My solution was to open an read/write pipe to the command with

# set up r/w pipe
set pipe [open | "telnet localhost" a+]

and then communicate with the telnet process via a loop of:

# read all output from pipe until eof
while {[ gets $pipe outputline] >= 0 } {
        <do something with $outputline>


# write to pipe and flush
puts $pipe $inputline
flush $pipe

Unfortunatly i could not even login ... the gets got stuck before reading the
"login:" line from the remote host. When i issue the gets by hand in a tclsh i
can read the "login :" line and correctly get an eof for the pipe, but can not
get the telnet process to recognize my puts.

I wonder if THIS IS THE WAY TO DO SUCH THINGS like connecting to some port of
some remote machine?

Please e-mail ..



Stefan Fuenfrocken,
TH-Darmstadt,     FB20 - Verteilte Systeme,  Alexanderstr. 6, 64283 Darmstadt,

http://www.*-*-*.com/ ~fuenf/  PGP(V2.3) public key on request
                    +Only skydivers know why birds sing+
                |                    \o/                   \|/
                |=>                  ((                   --O--
                |                     \\                   /|\

Tue, 16 Dec 1997 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Capturing output from exec'ed command

2. Using import in an exec'ed string

3. return val of exec'ed prog

4. interaction with exec'ed process

5. How to pass arguments to program been exec'ed

6. waiting for an exec'ed process to finish

7. Redirecting output of a exec'ed application

8. expect's interact command and timeouts

9. Strangeness from the arg'ed command line

10. handling errors from spawn'ed commands in Expect

11. Using '*'in exec command on UNIX

12. 'exec' command


Powered by phpBB® Forum Software