|
From: Olivier A. <Oli...@if...> - 2002-04-18 13:09:24
|
RGi...@a1... wrote:
>>I'm trying to exit perl whith an exit code after doing some expect
>>stuff, but the exit code is always set to 1. What I'm doing wrong ?
>>here is my test code:
>>#!/usr/bin/perl -w
>>use strict;
>>use Expect;
>>
>>my $exp=Expect->spawn("csh") or die "error: $!";
>>print $exp "exit 3";
>>exit 3;
>>
>>
>>%./test.pl
>>%echo ?$
>>
> ^^ I hope this is only a typo....
>
yes it was
>>1
>>%
>>
>
>Try "perl -e 'exit 3'; echo $?", which should print "3". '$?' is only
>valid within the same shell command, so it's no wonder you don't see
>it...
>
>If you want to capture the exit status of a spawned process, try
>
> my $exp = Expect->spawn("csh");
> $exp->send("exit 3\n");
> $exp->expect(5);
> print "exitstatus: ".$exp->exitstatus."\n";
>
>which prints "exitstatus: 768" on my system.
>
$exp->expect(5);
$exp->exitstatus;
that's definitivly help me. Many thanks!
>
>
>Hope this helps,
>
>Roland
>--
>RGi...@cp...
>
--
Olivier
|