[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Is there a class that can control the command window

Olivia Dou

11/21/2006 9:10:00 AM

I use ruby to do testing.
There are some scenario that look like this:
1) Do some navigation in the web browser and do some operation in it
2) run some command, especially telnet to another machine and then run
the commands
3) operate the browser again
4) run command in the telnet window again.


Now I use watir(Web application Testing in Ruby) to do navigation and
operations in the IE browser, the script look like this:
$ie.goto("http://localhost:8080")
$ie.frame("basefrm").button(:value,"Add Report").click()

And what I need exactly is a similar ruby lib that I can use to write
the script like this style:
cmdWindow.InputCommand("net user newUser /add")

I know that I can use NET::Telnet if I want to do telnet related
operations, and when executing the local commands, may use system(cmd),
but I want to identify the specified command window, and run the
following commands in that window.

I wonder whether I have made the questiong clear.

--
Posted via http://www.ruby-....

6 Answers

paul.rogers

11/21/2006 4:22:00 PM

0

I think you want to use Expect, and the ruby bindings for it

http://wiki.rubygarden.org/Ruby/page/sh...

I dont think Ive ever used it in ruby, but its popular in other
languages

Paul


Olivia Dou wrote:
> I use ruby to do testing.
> There are some scenario that look like this:
> 1) Do some navigation in the web browser and do some operation in it
> 2) run some command, especially telnet to another machine and then run
> the commands
> 3) operate the browser again
> 4) run command in the telnet window again.
>
>
> Now I use watir(Web application Testing in Ruby) to do navigation and
> operations in the IE browser, the script look like this:
> $ie.goto("http://localhost:8080")
> $ie.frame("basefrm").button(:value,"Add Report").click()
>
> And what I need exactly is a similar ruby lib that I can use to write
> the script like this style:
> cmdWindow.InputCommand("net user newUser /add")
>
> I know that I can use NET::Telnet if I want to do telnet related
> operations, and when executing the local commands, may use system(cmd),
> but I want to identify the specified command window, and run the
> following commands in that window.
>
> I wonder whether I have made the questiong clear.
>
> --
> Posted via http://www.ruby-....

Daniel Berger

11/21/2006 4:34:00 PM

0

<snip>

paul.rogers@shaw.ca wrote:
> I think you want to use Expect, and the ruby bindings for it
>
> http://wiki.rubygarden.org/Ruby/page/sh...
>
> I dont think Ive ever used it in ruby, but its popular in other
> languages
>
> Paul

It doesn't work on Windows afaik, which is the platform I'm guessing
the OP is on based on the mention of IE and Watir. However, there is
win32-console:

http://rubyforge.org/projects/win...

Perhaps that can help. There's no test framework built up around it,
though. You'll have to do that yourself. If you do, please create a
project for it. Seems like a good idea. :)

Regards,

Dan

Olivia Dou

11/22/2006 1:46:00 AM

0

shiwei zhang wrote:
> The following api in Ruby provides you a way to run OS cmd in cmd
> window:
> exec(command [, arg, ...]);
>
> Rgds,

No, I know exec and system is the method to run OS cmd in cmd window,
but what I need is a class that can represent the command window.

There is a ruby lib vruby that can represent the windows GUI such as
form, dialog, but I didn't see one that can represent the command
window/command prompt.

--
Posted via http://www.ruby-....

Daniel Martin

11/22/2006 5:22:00 AM

0

Olivia Dou <dou_yifan@yahoo.com> writes:

> No, I know exec and system is the method to run OS cmd in cmd window,
> but what I need is a class that can represent the command window.
>
> There is a ruby lib vruby that can represent the windows GUI such as
> form, dialog, but I didn't see one that can represent the command
> window/command prompt.

It sounds as though you're looking for Win32::Console

http://rubyforge.org/projects/win...

It's a little bit out of date, so you'll need to compile a new version
for whatever version of ruby you have.

--
s=%q( Daniel Martin -- martin@snowplow.org
puts "s=%q(#{s})",s.map{|i|i}[1] )
puts "s=%q(#{s})",s.map{|i|i}[1]

Olivia Dou

11/22/2006 5:44:00 AM

0

Daniel Martin wrote:
> Olivia Dou <dou_yifan@yahoo.com> writes:
>
>> No, I know exec and system is the method to run OS cmd in cmd window,
>> but what I need is a class that can represent the command window.
>>
>> There is a ruby lib vruby that can represent the windows GUI such as
>> form, dialog, but I didn't see one that can represent the command
>> window/command prompt.
>
> It sounds as though you're looking for Win32::Console
>
> http://rubyforge.org/projects/win...
>
> It's a little bit out of date, so you'll need to compile a new version
> for whatever version of ruby you have.

Thanks, Daniel.
I did a quick research on Win32::Console, and it seems that the
Win32::Console objects represents the console window the ruby script is
run in, isn't it?
If so, I'm afraid it is still not exactly what I want,:(


--
Posted via http://www.ruby-....

Martin DeMello

11/22/2006 12:11:00 PM

0

On 11/21/06, Olivia Dou <dou_yifan@yahoo.com> wrote:
>
> And what I need exactly is a similar ruby lib that I can use to write
> the script like this style:
> cmdWindow.InputCommand("net user newUser /add")

If you don't find anything, you could probably use popen4 as the basis
for writing your own:

http://popen4.ruby...

martin