How to run script/server in a thread?

I have an application in which a server part has been written using
rails, and the client part using firewatir. I would like to fire both
up with a single command. What mistake am I making below? I am
running this from the app root folder, where I am able to fire up irb
and successfully feed it exec(‘script/server’).

Warmly, Arun

#!/usr/bin/env ruby
require ‘rubygems’
#Include the FireWatir file.
require ‘firewatir’
#include the FireWatir Module.
include FireWatir
begin
th=Thread.new{exec(‘script/server’)}
sleep(3) #to give the server time to start. Is there a better way?
ff=Firefox.new
ff.goto(“http://localhost:3000”)
sleep (5)
ensure
ff.close
th.terminate
end


Your error is the use of exec() - exec() overwrites the whole process
(all threads) with the new program. Use the system() instead…

izidor

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs