Forum: Ruby More 'system call' troubleshooting

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
barjunk (Guest)
on 2007-04-11 21:35
(Received via mailing list)
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.
Tim H. (Guest)
on 2007-04-11 21:56
barjunk wrote:
> Can anyone explain the $? values?  It is supposed to contain a
> 'detailed error code'.

$? is a Process::Status value.

ri Process::Status
This topic is locked and can not be replied to.