regie@ireq-robot.hydro.qc.ca (Regis Houde) (05/07/91)
I wrote a program that intercepts the output of the standard
/usr/ucb/Mail program in order to interpret and replace a set of
characters. I'd like the program to behave exactly like the original
one so a program calling it (as mailtool) won't make any difference.
Here is my program :
#!/usr/bin/perl
# Name : Mail
# Usage : Mail
# Make the stdio unbuffered
select((select(stdout), $| = 1)[0]);
select((select(stdin), $| = 1)[0]);
open(IN,"/usr/ucb/mail @ARGV |");
while(<IN>)
{
# Some simple code here
print ;
}
It does pretty well except for the prompt that doesn't come at the
right time and this seems to bug mailtool when a user press the delete
button.
Any idea?
Thanks
merlyn@iwarp.intel.com (Randal L. Schwartz) (05/08/91)
In article <6819@s3.ireq.hydro.qc.ca>, regie@ireq-robot (Regis Houde) writes: | | I wrote a program that intercepts the output of the standard | /usr/ucb/Mail program in order to interpret and replace a set of | characters. I'd like the program to behave exactly like the original | one so a program calling it (as mailtool) won't make any difference. | | Here is my program : [program that opens Mail on a stdout pipe deleted] | It does pretty well except for the prompt that doesn't come at the | right time and this seems to bug mailtool when a user press the delete | button. | | Any idea? If I remember correctly, /usr/ucb/Mail does different things depending on whether it is run from a tty or not. Since you are opening the program with stdout attached to a pipe rather than a tty, I bet Mail is getting confused. You'll need to run Mail inside a pty. There have been a few packages floating through here in the last few months (chat2.pl included) that'd do that for you. (I think that's the problem. If someone else has more info, please chime in. I haven't touched Mail in years.) print substr("Just another Perl hacker, or something like that...", 0, 25) -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/
lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) (05/09/91)
In article <6819@s3.ireq.hydro.qc.ca> regie@ireq-robot.hydro.qc.ca (Regis Houde) writes:
:
: I wrote a program that intercepts the output of the standard
: /usr/ucb/Mail program in order to interpret and replace a set of
: characters. I'd like the program to behave exactly like the original
: one so a program calling it (as mailtool) won't make any difference.
:
: Here is my program :
:
: #!/usr/bin/perl
: # Name : Mail
: # Usage : Mail
:
: # Make the stdio unbuffered
: select((select(stdout), $| = 1)[0]);
: select((select(stdin), $| = 1)[0]);
:
: open(IN,"/usr/ucb/mail @ARGV |");
:
: while(<IN>)
: {
: # Some simple code here
: print ;
: }
:
: It does pretty well except for the prompt that doesn't come at the
: right time and this seems to bug mailtool when a user press the delete
: button.
I don't know if it's the whole story, but <IN> does line-oriented input,
so any prompt not ending in newline is going to languish in the STDIN
buffer until a newline comes along. Setting $| on STDIN has no effect.
Replace the <IN> with sysread(STDIN,$_,1024) or read(STDIN,$_,1) and it
should be closer to the truth.
Larry