From: <RGi...@a1...> - 2002-04-18 10:14:19
|
> 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.... > 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. Hope this helps, Roland -- RGi...@cp... |