Re: how to get a return value from a shell script?
Re: how to get a return value from a shell script?
- Subject: Re: how to get a return value from a shell script?
- From: Bill Coderre <email@hidden>
- Date: Tue, 10 Oct 2006 17:04:53 -0700
On Oct 10, 2006, at 3:44 PM, Ben Zhu wrote:
I am wrinting an installer using packageMaker.
In my installer, I have an InstallationCheck perl script to call a
shell script that returns an exit status.
The shell script file is put under the same directory of
InstallationCheck file and set to the execute mode.
In the InstallationCheck script, I have:
my $rv = 0;
$rv = system('checkMyInstall');
After running this script, the return value always was -1;
http://perldoc.perl.org/functions/system.html describes system() and
says that -1 means that your checkMyInstall did not run. (It also
shows a simple piece of code to find the return value/exit code.)
This is because the working directory is something strange. So you
need to be more specific.
Try this instead:
system($ARGV[0]."/Contents/Resources/myCheckInstall");
Now use that web page's code to examine and decode $?
if ($? == -1) {
print "failed to execute: $!\n";
}
elsif ($? & 127) {
printf "child died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
}
else {
printf "child exited with value %d\n", $? >> 8;
}
I am not sure what the working directory is supposed to be set to. It
might be documented somewhere, but I can't recall seeing anything. I
don't rely on that value, but maybe it is reliable and I don't know
it. Anyway, $ARGV[0] is very reliable.
It IS documented (along with the other environment variables) here:
http://developer.apple.com/documentation/DeveloperTools/Conceptual/
SoftwareDistribution/Install_Operations/chapter_8_section_3.html
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden