# Unable to run(automate) different file via Ruby

**URL:** <https://www.ruby-forum.com/t/unable-to-run-automate-different-file-via-ruby/138371>\
**Category:** Ruby\
**Created:** [May 22, 2008, 11:28am UTC](https://www.ruby-forum.com/t/unable-to-run-automate-different-file-via-ruby/138371 "2008-05-22T11:28:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pranjal\_jain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac91a4/32.png) [@pranjal\_jain](https://www.ruby-forum.com/u/pranjal_jain)\
**Post date:** [May 22, 2008, 11:28am UTC](https://www.ruby-forum.com/t/unable-to-run-automate-different-file-via-ruby/138371/1 "2008-05-22T11:28:14Z")

</div>

Hi  
I am having a LoadRunner File which I want to run via Ruby Script.  
I am trying to execute it proper functioning, but can’t.

I am putting the script here; please suggest if i am committing any  
mistake.

Script is as follows :

# WinClicker Library of Watir module required

require ‘watir/winClicker’

# path of the script is specified

Dir.chdir(“d:/Load Runner/gmail”) {system(“gmail.usr”)}  
#sleep 25  
#wsh.SendKeys(’{F5}’)

Thankx in advance 🙂

---

<div class="post-metadata">

**Author:** ![pranjal\_jain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac91a4/32.png) [@pranjal\_jain](https://www.ruby-forum.com/u/pranjal_jain)\
**Post date:** [May 22, 2008, 5:42pm UTC](https://www.ruby-forum.com/t/unable-to-run-automate-different-file-via-ruby/138371/2 "2008-05-22T17:42:53Z")

</div>

On Thu, May 22, 2008 at 4:28 AM, Pranjal J.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> # WinClicker Library of Watir module required
> 
> require ‘watir/winClicker’
> 
> # path of the script is specified
> 
> Dir.chdir(“d:/Load Runner/gmail”) {system(“gmail.usr”)}

Kernel.system doesn’t know how to handle these files. You’d get the  
same thing if you tried to run a ruby file:

# test .rb

puts ‘hello world’

# irb session

> > system(‘test.rb’)  
> > =\> false  
> > system(‘ruby test.rb’)  
> > hello world  
> > =\> true  
> > system(‘call test.rb’)  
> > hello world  
> > =\> true

So, either write the command so that it calls the executable that runs  
your .usr file, or use ‘call’.

Hope that helps,

Gordon

---

<div class="post-metadata">

**Author:** ![pranjal\_jain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac91a4/32.png) [@pranjal\_jain](https://www.ruby-forum.com/u/pranjal_jain)\
**Post date:** [May 23, 2008, 7:07am UTC](https://www.ruby-forum.com/t/unable-to-run-automate-different-file-via-ruby/138371/3 "2008-05-23T07:07:02Z")

</div>

HI Gordon  
Thankx it worked.  
But now I am facing a new problem, when I want to run tht script , I  
cant do it.  
the script is as follows :

# This script can drive any scripts return anywhere on system

# WinClicker Library of Watir module required

require ‘watir/winClicker’  
require ‘win32ole’

wsh = WIN32OLE.new(‘Wscript.Shell’)

# path of the script is specified

Dir.chdir(“d:/Load Runner/gmail”) {system(“call gmail.usr”)}  
puts “Start”  
sleep 3  
wsh.SendKeys(‘%u’)  
wsh.SendKeys(‘R’)

# Wait for 2 seconds

sleep 2  
puts “end”

Thankx in advance 🙂

Gordon T. wrote:

> On Thu, May 22, 2008 at 4:28 AM, Pranjal J.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > # WinClicker Library of Watir module required
> > 
> > require ‘watir/winClicker’
> > 
> > # path of the script is specified
> > 
> > Dir.chdir(“d:/Load Runner/gmail”) {system(“gmail.usr”)}
> 
> Kernel.system doesn’t know how to handle these files. You’d get the  
> same thing if you tried to run a ruby file:
> 
> # test .rb
> 
> puts ‘hello world’
> 
> # irb session
> 
> > > system(‘test.rb’)  
> > > =\> false  
> > > system(‘ruby test.rb’)  
> > > hello world  
> > > =\> true  
> > > system(‘call test.rb’)  
> > > hello world  
> > > =\> true
> 
> So, either write the command so that it calls the executable that runs  
> your .usr file, or use ‘call’.
> 
> Hope that helps,
> 
> Gordon

---

<div class="post-metadata">

**Author:** ![pranjal\_jain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac91a4/32.png) [@pranjal\_jain](https://www.ruby-forum.com/u/pranjal_jain)\
**Post date:** [May 23, 2008, 3:42pm UTC](https://www.ruby-forum.com/t/unable-to-run-automate-different-file-via-ruby/138371/4 "2008-05-23T15:42:32Z")

</div>

On Fri, May 23, 2008 at 12:07 AM, Pranjal J.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> HI Gordon  
> Thankx it worked.  
> But now I am facing a new problem, when I want to run tht script , I  
> cant do it.

I’m not sure I understand your problem, but if you’re wanting to just  
start gmail.usr, and continue with your script without waiting for it  
to finish, you can change call to start. This will start gmail.usr in  
a different cmd window.

Gordon
