At 1:59 PM -0700 1/7/04, Michael Downey wrote:
>I believe I have another problem with the way Perl is doing the spawning of
>subprocesses.  Here is an example.  I built a DCL script called TEST.COM
>which is as follows:
>    $ INQUIRE A "Enter data to print"
>    $ WRITE SYS$OUTPUT "Received: ''A'"
>
>Then I built a TEST.PL script which is as follows:
>    use strict;
>
>    open(SPWN, '|@test.com') or die "Failed to spawn test.com due to error:
>$!\n";
>
>    print SPWN "ABC\n";
>    close(SPWN);
>
>    print "Complete\n";
>
>If you run test.pl under 5.8 it does not do what is expected which is print
>out "Received: ABC" right away.  What it does is not pick up the data being
>printed to it and wait for input from the user.  If you run test.pl under
>5.6.1 it does work correctly.
>
>Interestingly enough if you spawn an executable instead of a DCL script
>everything works correctly under 5.8.  I regrettably haven't been able to
>test this using the very latest Perl so if someone could do a quick test
>that would be much appreciated.  I am currently running my test on VMS 7.3-1
>using the latest DEC C compiler.  I've tested on both 5.8.0 and 5.8.1 of
>Perl.

Yeah, this is nasty stuff and I think has affected you before as
well.  I'm sorry it hasn't been fixed, but I don't know how to fix it
without breaking other things.  The basic issue, IIRC, is that when a
command procedure is executed, SYS$INPUT is defined to be the
procedure.  vmspipe.com reassigns SYS$INPUT to the pipe passed in via
symbol, but SYS$COMMAND is inherited from the parent, which is why
your INQUIRE still prompts the terminal.

If you replace your test.com with the following one, you can get the
behavior you are expecting, though I make no promises that it covers
all cases.  Basically if sys$input is a mailbox, it opens it for
reading; otherwise it goes after sys$command like it normally would.

$ type test.com
$ if f$getdvi("sys$input","devtype") .eqs. "1"
$ then
$   open/read pipe sys$input
$ else
$   define pipe sys$command
$ endif
$ READ/PROMPT="Enter data to print: " pipe A
$ WRITE SYS$OUTPUT "Received: ''A'"


-- 
________________________________________
Craig A. Berry
mailto:[EMAIL PROTECTED]

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser

Reply via email to