Re: how to get a return value from a shell script?
site_archiver@lists.apple.com Delivered-To: installer-dev@lists.apple.com my $rv = 0; $rv = system('checkMyInstall'); After running this script, the return value always was -1; 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; } _______________________________________________ Do not post admin requests to the list. They will be ignored. Installer-dev mailing list (Installer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/installer-dev/site_archiver%40lists.a... 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: 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. 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 This email sent to site_archiver@lists.apple.com
participants (1)
-
Bill Coderre