Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Return codes

Reply
Thread Tools

Return codes

 
 
Peter Hug
Guest
Posts: n/a
 
      03-11-2008
I'd like to be able to launch a little ruby application from within a
shell script or a windows command file. How can my Ruby application
return error or success codes such that the callee can verify the result
easily both in Linux and Windows?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Tim Hunter
Guest
Posts: n/a
 
      03-11-2008
Peter Hug wrote:
> I'd like to be able to launch a little ruby application from within a
> shell script or a windows command file. How can my Ruby application
> return error or success codes such that the callee can verify the result
> easily both in Linux and Windows?


$ ri Kernel#exit
------------------------------------------------------------ Kernel#exit
exit(integer=0)
Kernel::exit(integer=0)
Process::exit(integer=0)
------------------------------------------------------------------------
Initiates the termination of the Ruby script by raising the
SystemExit exception. This exception may be caught. The optional
parameter is used to return a status code to the invoking
environment.


--
RMagick: http://rmagick.rubyforge.org/
RMagick 2: http://rmagick.rubyforge.org/rmagick2.html

 
Reply With Quote
 
 
 
 
Peter Hug
Guest
Posts: n/a
 
      03-11-2008
Perfect! Many thanks Tim.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Robert Klemme
Guest
Posts: n/a
 
      03-11-2008
2008/3/11, Peter Hug <(E-Mail Removed)>:
> Perfect! Many thanks Tim.


Additional note: it is sufficient to throw an exception or not. Ruby
will automatically set the exit code appropriately:

18:06:55 /cygdrive/c/SCMws/Tickets/oz-26255_no_txid
$ ruby -e '123'; echo $?
0
18:07:03 /cygdrive/c/SCMws/Tickets/oz-26255_no_txid
$ ruby -e 'raise "foo"'; echo $?
-e:1: foo (RuntimeError)
1
18:07:06 /cygdrive/c/SCMws/Tickets/oz-26255_no_txid
$

Kind regards

robert

--
use.inject do |as, often| as.you_can - without end

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write codes to connect access database using html codes hiralcp Software 0 12-18-2007 08:49 PM
How to use file I/o codes with form and controls codes Allen ASP .Net 1 12-03-2007 12:04 AM
Virtual Key Codes, Scan Codes and ASCII Codes in C gj_williams2000@yahoo.co.uk C Programming 2 08-20-2005 11:04 AM
RegEx replace of html codes to ascii codes Greg -- ASP .Net 4 08-09-2005 07:27 PM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM



Advertisments