From: Austin S. <te...@of...> - 2002-03-02 07:58:04
|
> > My first try was to write a short Perl program that spawned a telnet, > > did an expect to get to the prompt, then did 'system("bash");' to get > > into the subshell. I then invoked program#2 which tried to interact > > with the telnet. I used the pty that the spawned telnet was using > > as fd's 0,1 and 2 (found via lsof) as the filename to re-open with > > exp_init(), but that didn't work. It did sent the data to the pty, > > but it was received by the parent program rather than the spawned telnet. > > I suspect I'probably running afoul of the pty master/slave business, > > which I'm not very familiar with. > > > > Any idea how to get what I want to happen? Is it even possible? > > > > It's possible, though it may not be what you want. You would do > something along the lines of close STDIN and STDOUT, then reopen them > with the filenumber of the tty, then exec() the program, e.g. bash. You > can look at the code for spawn() to see how this is done to open the initial > program. Also you will need to make sure you set raw mode on the pty, or > you will have processes echoing at themselves. Come to think of it, this might be something that would be worth adding as a routine in the module, though I'm not sure when someone would use it. Conceptually it sounds like something someone would want to do, but I've never had an occasion to. Austin |