telnet using tcl script - help ! 
Author Message
 telnet using tcl script - help !

Hi all,

I'm a new user to tcl. love the language.
Please help me with this little problem, and you'd have encouraged
a budding tcl enthusiast to strive to be a future tcl swamy...

I have a procedure which I call connect.

proc connect {} {

    # telnet to the following fixed ip address.
    exec telnet 16.23.34.196

Quote:
}

When I execute this procedure from the tcl prompt in a tcl shell,
the whole thing just gets stuck.
If I press "Enter" repeatedly, it eventually throws me back
to the tcl shell. (It appears that it is taking my "Enter" keys
for the login and password and eventually fails).

I'm sure this is some kind of I/O redirection thing. Is there any
way I can write such a tcl script ?  Please help.

More Info:
Why do I need such a method ? I want to eventually write
a script so a user can type something like: "connect machine2"
My script will then take machine2, resolves it's ip address from a
lookup table and will internally call "telnet x.y.z.k"
The telnet part is where I am getting stuck !

Any help greatly appreciated !

   - V9

ps. btw this is in a Windows NT environment. However feel free to
assume a Unix env if that's the domain you are familiar with.

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



Sat, 14 Dec 2002 03:00:00 GMT  
 telnet using tcl script - help !
Have a look at Expect


Quote:
> Hi all,

> I'm a new user to tcl. love the language.
> Please help me with this little problem, and you'd have encouraged
> a budding tcl enthusiast to strive to be a future tcl swamy...

> I have a procedure which I call connect.

> proc connect {} {

>     # telnet to the following fixed ip address.
>     exec telnet 16.23.34.196
> }

> When I execute this procedure from the tcl prompt in a tcl shell,
> the whole thing just gets stuck.
> If I press "Enter" repeatedly, it eventually throws me back
> to the tcl shell. (It appears that it is taking my "Enter" keys
> for the login and password and eventually fails).

> I'm sure this is some kind of I/O redirection thing. Is there any
> way I can write such a tcl script ?  Please help.

> More Info:
> Why do I need such a method ? I want to eventually write
> a script so a user can type something like: "connect machine2"
> My script will then take machine2, resolves it's ip address from a
> lookup table and will internally call "telnet x.y.z.k"
> The telnet part is where I am getting stuck !

> Any help greatly appreciated !

>    - V9

> ps. btw this is in a Windows NT environment. However feel free to
> assume a Unix env if that's the domain you are familiar with.

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



Sat, 14 Dec 2002 03:00:00 GMT  
 telnet using tcl script - help !


Quote:
>Have a look at Expect



                        .
                        .
                        .
Quote:
>> Why do I need such a method ? I want to eventually write
>> a script so a user can type something like: "connect machine2"
>> My script will then take machine2, resolves it's ip address from a
>> lookup table and will internally call "telnet x.y.z.k"
>> The telnet part is where I am getting stuck !

                        .
                        .
                        .
Mr. Cailly's right:  you *really* want to learn about Expect
<URL:http://starbase.neosoft.com/~claird/comp.lang.tcl/expect.html>.
It's the exact answer for your needs.
--


Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



Sat, 14 Dec 2002 03:00:00 GMT  
 telnet using tcl script - help !

Quote:



> >Have a look at Expect


>                         .
>                         .
>                         .
> >> Why do I need such a method ? I want to eventually write
> >> a script so a user can type something like: "connect machine2"
> >> My script will then take machine2, resolves it's ip address from a
> >> lookup table and will internally call "telnet x.y.z.k"
> >> The telnet part is where I am getting stuck !
>                         .
>                         .
>                         .
> Mr. Cailly's right:  you *really* want to learn about Expect
> <URL:http://starbase.neosoft.com/~claird/comp.lang.tcl/expect.html>.
> It's the exact answer for your needs.
> --


> Business:  http://www.Phaseit.net
> Personal:  http://starbase.neosoft.com/~claird/home.html

Check the following telnet script included in the Expect distribution.
It doesn't get easier than this

# Start telnet and when you press ^Z, put telnet in background and save
any
# remaining output in "telnet.log".  You can actually apply this
technique
# to any interactive program - I just chose telnet here.

# Author: Don Libes, NIST, 1/5/95

spawn -ignore HUP telnet $argv          ;# start telnet
interact \032 return                    ;# interact until ^Z

if [fork] exit                          ;# disconnect from terminal
disconnect

set log [open logfile w]                ;# open logfile
expect -re .+ {                         ;# and record everything to it
        puts -nonewline $log $expect_out(buffer)
        exp_continue

Quote:
}

# Start telnet and when you press ^Z, put telnet in background and save
any
# remaining output in "telnet.log".  You can actually apply this
technique
# to any interactive program - I just chose telnet here.

# Author: Don Libes, NIST, 1/5/95

spawn -ignore HUP telnet $argv          ;# start telnet
interact \032 return                    ;# interact until ^Z

if [fork] exit                          ;# disconnect from terminal
disconnect

set log [open logfile w]                ;# open logfile
expect -re .+ {                         ;# and record everything to it
        puts -nonewline $log $expect_out(buffer)
        exp_continue

- Show quoted text -

Quote:
}



Sat, 14 Dec 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using tcl telnet client with Windows telnet server

2. Expect script changing telnet escape using `set escape ^\` problem

3. How to make telnet script invisible -tcl/expect??

4. Help with using TCL scripts with Smart Bits (from Netcom Systems)

5. Need help using Tcl for CGI script

6. Running a TK script using wish80.exe within a tcl script

7. Need example of working tcl/tk script used as cgi-bin script

8. TCL using Telnet and Ixia packet generator

9. TELNET to UNIX from NT using TCL

10. Using telnet from tcl

11. using telnet via tcl

12. Help: Expect using Telnet from cgi. WEIRD

 

 
Powered by phpBB® Forum Software