[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Changing variables mid-script

Joel VanderWerf

5/29/2007 6:24:00 PM

Fred Phillips wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Say I had a script which read:
>
> task.start
> while $connect do
> task.receive
> end
> task.stop
>
>
>
> Could I make the variable $connect false whilst the script it running from
> an outside source, other than reading from a file?

Yes. You could use a signal handler or DRb, for example. For signals,
put this somewhere before your while loop:

trap "USR1" do
$connect = false
end

Then "kill -USR1 <insert-your-pid-here>" will cause $connect to become
false.

DRb is more complicated, but exposes a much richer interface.

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407