From: Ed R. <er...@pa...> - 2002-03-02 22:27:12
|
Austin Schutz writes: > On Sat, Mar 02, 2002 at 12:40:25AM -0500, Ed Ravin wrote: > > Here's what I'd like to do with Expect.pm: > > * Spawn a telnet to somewhere. > > * Invoke a subshell > > * From within that subshell, call another Perl program one or more > > times to interact with the telnet process spawned by the parent process. > Thirdly, you could have the called perl program call the telnet > expect process and work with it as if it were any other process. It's hard to > tell (for me anyway) what you're trying to accomplish. What I want to do (and why this option won't work) is to set up Kerberized telnet or ssh session to a Cisco router, drop into a shell, and be able to run shell commands that manipulate the router via the session. I've already got this working with regular (cleartext) telnet sessions - the filehandle with the telnet session is inherited by telnet's children - I subshell from telnet and then have the Perl/Expect program use exp_init() to hook up to fd3 and I'm all set. I can call the Perl/Expect program multiple times to manipulate the router via the Telnet session, I can call the editor or other shell programs as needed, and when I'm done I exit the shell and return back to the telnet prompt. But for an ssh or Kerberized telnet session, that won't work - telnet or ssh has to stay running to encrypt/decrypt the data - the only way to talk to the remote router is via the pty of ssh/telnet. I could have the perl/expect program start ssh/telnet, but my program is meant to be a tool that you run multiple times against the router, so I want the ssh/ telnet to persist. > Another way is to have an expect script that does interact() at > some point and uses named pipes as i/o. I think that's how things like > kibitz work. Performance-wise it's less efficient, but probably easier to > code. Easy to code, I like that :-). I had earlier tried using ksh93, which has a built-in for doing this - when you start a process and background it with "|&" instead of "&", you end up with two pipes (meant for use with ksh's "read -p" and "print -p" commands). I suppose I can try hooking one of the pipes to the Expect object, and teaching my script to send the output data for the telnet/ssh session to the other? |