More 'system call' troubleshooting

B

barjunk

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top