On Monday, July 1, 2002, at 10:09 , Vitor Carlos Flausino wrote:

short answer - IF you want to 'grab' the 'return of information
as seen at the command line' then you may wish to do

        my $cmd = "xmessage";
        my $cmd_args = '-default No -nearmouse -buttons Yes:2,No:3 Do you 
realy want to run Daily TVG?'

        open(XMSG, "$cmd $cmd_args |") or die "unable to open $cmd with 
$cmd_args: $!\n";

        while(<XMSG>) {
                # parse out the response that it would jin up
        }
        close XARGS;

when you play with the $? you are looking at the 'exit value' of
the last 'backgrounded' process - just as in /bin/[ba|c|k]sh....

[..]
> The result is 26112 when i press Yes and 25856 when I press No (????????)
> .
> If I run from the command line, the result is ok (2/3).

> What is going on???

Phase One - perldoc -f system

will help you resolve that it suggests


"               You can check all the failure possibilities by
                inspecting `$?' like this:

                    $exit_value  = $? >> 8;
                    $signal_num  = $? & 127;
                    $dumped_core = $? & 128;
"

we note then:

[jeeves:~/lib/perl] drieux% perl -e '$val=26112 ; $a = $val >> 8; print $a,
"\n";'
102
[jeeves:~/lib/perl] drieux%  perl -e '$val=25856; $a = $val >> 8; print $a,
"\n";'
101
[jeeves:~/lib/perl] drieux%

so let's step along to what this 'from the comand line'
is suppose to mean - do you mean the 'output' from the
running of a command - or the 'return value' -
[jeeves:~/lib/perl] drieux% echo $SHELL
/bin/csh
[jeeves:~/lib/perl] drieux% echo $?
0
[jeeves:~/lib/perl] drieux% sh -c "exit 5"
[jeeves:~/lib/perl] drieux% echo $?
5
[jeeves:~/lib/perl] drieux%

note that in this case  I ran a 'command line shell script'
that simply set the exit value to 5 - hence at the shell I
could test that value with the echo $?...

in perl that would have been

[jeeves:~/lib/perl] drieux% perl -e 'exit(12);'
[jeeves:~/lib/perl] drieux% echo $?
12
[jeeves:~/lib/perl] drieux%

so assuming that you meant to deal with the 'exit value'
of your xmessage - in perl then currently they are
returning 102 and 101 -

note the manpage at
        http://www.xfree86.org/4.2.0/xmessage.1.html

indicates that there is the action
        exit(value)

so what you may want to check is what is actually
being done at the command line - to get the 'value'
of the status line.




ciao
drieux

---

deep emoitonal crisis time

        /bin/[ba|c|k]sh

would that really be a great name for notPerl????



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to