In case of exit 0: - does the shell script return 0 in perl script $? Variable
but for the case with output 1: - return 256 so that it needs to be shifted by 8 so try the following:
#!/usr/bin/perl print "pelr"; system("./shell.sh"); $p=$?>>8; print $p;
NOTE. In the shell script, just type exit 0 and run and then exit 1. and look o / p
Just note that when using the system in perl, it returns the exit code multiplied by 256. Thus, if the command returns 1, the system ("command") will return 256. So, to get the actual return value, divide by 256.
source share