[Backgroundrb-devel] rescue?

mattp at digimonkey.com mattp at digimonkey.com
Wed Sep 6 15:41:53 EDT 2006

Probably a simple question, but humor me:

Let's say I have a page (in Rails) that lets a user type a shell  
command (say, 'ping blah.com') into a form and it fires off a worker  
that then updates that page using AJAX (all of this is working so far).

How would I correctly wrap the worker in a begin..rescue so that it  
spits out 'invalid command' when someone types in something incorrect.

Right now, I have:

   def start_working
         @result = IO.popen(@cmd)
       rescue SystemCallError
         @result = "Invalid or Failed Command: " + $!

but in my view, the @result doesn't seem to be accessible to the ajax  
periodical updater in the same way the @result from the popen is...  
what am i missing?


More information about the Backgroundrb-devel mailing list