aurux has asked for the wisdom of the Perl Monks concerning the following question:

hi monks,

i've built a script for logging into several routers from a xterm for each session.
for interactivity, i used Expect.pm, which works but its not fast as pure telnet connection.
anyway, its the only way for user interactiion i've found.

basic function:
i have one xterm as mainwindow which reads the hostname and starts another xterm that starts the telnet session to the router.
actually, the user and password handling is made over sockets.
mainwindow acts as a tcp server and starts a 'xterm -e telnet.pl <randomseed> <randomport>' as a tcp client.
once started, it connects to the server which sends the routerlogin and password client (telnet.pl) an all works as intended.

but i dont like the way the login data is handled, because:
- network connections on the same host as client/server isn't really a useful way
- it's not multiuser compatible
what i want (and tried, useless):
- fork a child for each routerconnection with bi-directional pipe for handling auth. data
- have an new xterm for each connection for STDIN/STDOUT.

my main problem is:
- howto get the child(s) spawn a xterm and use it for stdio

and:
- how can i get rid of the Expect.pm and give the stdio control to the user/xterm after doing the login stuff?

working on AIX 4.3.3 with perl 5.005_03 built for aix

thx for any hints...
sorry for the english, no native speaker inside ,)

Replies are listed 'Best First'.
Re: launch xterm for STDIO to perl script for telnet
by bellaire (Hermit) on Mar 19, 2009 at 12:57 UTC
    I'm not sure I'm understanding your write-up, so I'll attempt to clarify. Why are you spawning an xterm in a child process, which connects via TCP back to its own parent, and having the parent do the connection to the router? Why don't you have the spawned child run a connection script on its own which connects directly to the router, not going through the parent? You would still need Expect.pm, but once the interactive login is complete, piping stdin/stdout to your router connection should be trivial.

    I think I am missing something.
Re: launch xterm for STDIO to perl script for telnet
by aurux (Initiate) on Mar 19, 2009 at 14:11 UTC
    what i have:

    1. parent.pl starts, prompt for login data (user/pw), starts socket server and waiting for a hostname via stdin
    2. once a hostname is typed, it executes a system("xterm -e client.pl") an waits for next input
    3. the client.pl (in its own terminal) connects to the parent an fetches the login data & hostname.
    4. then the client.pl opens a connection via expect.pm to the router, authenticates and gives the user control over the terminal

    what i want:

    1. script starts, prompt for login data (user/pw) and waiting for a hostname via stdin.
    2. once a hostname is typed, a process(child) is forked and login data & hostname is piped to it.
    3. the child starts its own xterm an connects therein to the router. <- no idea howto !?
    4. after the authentication procedure, stdio is given to the user via the xterm <- also no idea howto..

    hope this explanation is more clear :)