Is there a class that can control the command window

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.

The following api in Ruby provides you a way to run OS cmd in cmd
window:
exec(command [, arg, …]);

Rgds,

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.

Olivia D. [email protected] 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/win32console/

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

Daniel M. wrote:

Olivia D. [email protected] 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/win32console/

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,:frowning:

On 11/21/06, Olivia D. [email protected] 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.rubyforge.org/

martin

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