More 'system call' troubleshooting


#1

Something that isn’t mentioned in the Ruby manual online (http://
www.rubycentral.com/book/ref_m_kernel.html#Kernel.system) is that the
entire path is needed as well.

Of course, that is a best practice, but I spent some time working
through this as an issue.

Additionally, I wrote a short test.sh script that does an exit with a
value. The command I used in ruby was:

retval = system("/path/to/test.sh")

when this is run the values for ‘retval’ and $? are as follows:

#exit 0 -> true $?=0
#exit 1 -> false $?=256
#exit 2 -> false $?=512
#exit 3 -> false $?=768
#exit 4 -> false $?=1024
#exit 5 -> false $?=1280
#exit -1 -> false $?=65280

Can anyone explain the $? values? It is supposed to contain a
‘detailed error code’.

By the looks of it, some sort of multiple of 256.

Mike B.


#2

barjunk wrote:

Can anyone explain the $? values? It is supposed to contain a
‘detailed error code’.

$? is a Process::Status value.

ri Process::Status