Command line arguments feeding automation

Hi everyone!

I am on ubuntu. I need to automate testing of small utility juice.exe.
Yes, that one is windows command line application. It runs ok from wine.
The problem is that juice.exe every time asks me from command line to
enter 3 values: ip, host and some param. If developer who developed it
would only new about command line arguments, life would be easier, I
would place something like this in rake:

wine juice.exe -i x.y.z.w -h host.com -p some_param

But little exe kid prompts me every time command line params.
Question:

Is there a way to automate providing arguments in that way?
I repeat that juice.exe is command line utility.

Thank you in advance.


http://blog.eugen.co

Can you get something to work with IO.popen? IO.popen allows you to use
a ruby program to read from juice.exe’s stdout, and you can use the ruby
program to write to juice.exe’s stdin.

So you could examine the question juice.exe sends to your ruby program
for a keyword, and then write the corresponding response(think hash).
Or, if you know that juice.exe asks for the same three things over and
over, you can just write a loop in your ruby program to write the three
responses.

One thing you have to know is: does juice.exe expect line oriented
input? In other words, does juice.exe consider a newline to be the end
of the response to its question? If so, then you need to write with
puts().

For reading, gets() will block until it reads a newline. Does juice.exe
end its questions with newlines? Do you even need to read the question?

IO.popen seems to be too complecated solution for simple problem.
I think I didn’t pose problem correctly.

Anyway, I solved it with help of expect utility.
http://en.wikipedia.org/wiki/Expect
It does great job in automation of this kind of situation.

Yes, solution is not ruby related. However, I am testing with test/unit

  • rake and inside I make use of ‘expect’. A good project idea is to
    write ‘expect’ like DSL that will probably use IO.popen as 7stud said
    above.

Thank you!

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