On 5/11/06, Chris McMahon <[EMAIL PROTECTED]> wrote:
On 5/11/06, Bret Pettichord <[EMAIL PROTECTED]> wrote:
> I don't understand the problem. Doesn't this do what you want?
>   Thread.new {system 'ruby c:/myscript.rb'}

Not really.  I like to do stuff like the code below now and then.
Furthermore, since each Ruby script is running in it's own process
(not in it's own thread), I don't have thread-safety issues, and I
don't get the kind of interference that Mr. Fitisoff encountered.
(Assume that the Ruby scripts both kick up a 401 Basic Auth logon
popup)

I still think you can do this in Ruby. The example i gave did not have the Ruby script running in a separate thread, but rather a separate process. Specifically, a new thread is started, from which a new process is started. The only purpose of the thread is to keep the controlling script from being blocked until the process completes. You specified that you needed a version of "system" that was non-blocking and that is what i gave you.

You are welcome to use Perl to run your Ruby scripts, but i really don't see any thing here that couldn't be done in Ruby if you use "system" as i've described and use the Ruby equivalent to Win32::GuiTest.

There are in fact advantages to using Perl threads over Ruby threads, but you aren't using Perl threads in the first place.

Bret

##########################

use Win32::GuiTest qw(FindWindowLike SetForegroundWindow SendKeys );

my $x = 0;
system (1, "ruby c:/logon_machine_one_and_do_Watir_stuff.rb");
while (1) { #INFINITE LOOP
sleep 2; #CHECK FOR NEW WINDOW EVERY 2 SEC
my @windows = FindWindowLike(0, "^Connect to machine 1");
for (@windows) {
SetForegroundWindow($_); #BRING THE RIGHT WINDOW IN FOCUS
SendKeys("userone{TAB}passwordone{ENTER}");
$x = 1;
}
exit if $x == 1;
}

my $y = 0;
system (1, "ruby c:/logon_machine_two_for_more_watir.rb");
while (1) { #INFINITE LOOP
sleep 2; #CHECK FOR NEW WINDOW EVERY 2 SEC
my @windows = FindWindowLike(0, "^Connect to machine 2");
for (@windows) {
SetForegroundWindow($_); #BRING THE RIGHT WINDOW IN FOCUS
SendKeys("usertwo{TAB}passwordtwo{ENTER}");
$y = 1;
}
exit if $y == 1;
}
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to