SPUG: shell script event loops + wrapping shell utilities
andrew at sweger.net
Sun Apr 21 13:39:54 CDT 2002
On Sat, 20 Apr 2002, dancerboy wrote:
> Hmmm... was my post not clear? This is exactly what I *wanted*:
Okay, sorry. Don't get your knickers in a twist. It was clear. I just
wasn't reading carefully enough (it's just way too sunny and warm here to
Beats me. I did some more digging and I wonder if this might be an example
of open3 deadlock. It's hard to say exactly what ftp is doing on the other
side of those filehandles (well, not true; the source is available).
Not necessarily related, but when I did a simple redirect of ftp's stdin,
stdout, & stderr (ftp < /dev/tty5 > /dev/tty6 2> /dev/tty7), it (ftp) was
still smart enough to prompt for the password on my shell's original tty.
I see you're checking on the parent's TTY and sending that back TO_SHELL.
That might be sending the "password:" prompt back to the ftp binary's
stdin (now on a pipe). In my experiment, while ftp was waiting for a
password (on my original tty), echo was turned back on for tty5 (because
ftp wasn't reading from there, instead waiting for my reply on the shell's
tty). So, ftp isn't doing anything to help make it simple.
It might be necessary to disconnect your program's stdin/stdout from the
tty before creating the pipes (and maybe creating new filehandles to talk
to the tty). That would put your program completely between the tty and
the child binary.
Since you're just wanting to add simple functionality, it might be simpler
to use expect. It deals with all the ugliness and still allows user
interaction. But then it wouldn't be as much fun, eh?
Andrew B. Sweger -- The great thing about multitasking is that several
things can go wrong at once.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list