What is the best way to verify the output of the run() command?

Asked by Hitesh Shah

I am a first time user of Sikuli. I have searched across the www but I haven't found an example of how to look for and grab a few things from the output of a command and assign them to variables. For example the output of the show interface commands has a lot of details of which I am interested only on the state of the interface (UP or DOWN), the input counter and the output counter.

Appreciate your help.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Using Sikuli features for that is overkill, since you would need the not very reliable OCR feature.

simply pipe the command output to a file and just process it.

… or from inside a script use:
result = run("someCommand parm1 parm2")
print result

result contains the textual output that the command produced on stdout AND stderror

Revision history for this message
Hitesh Shah (hitesh-shah) said :
#2

Thank you so much for your reply.
For an end to end test, I have to run some browser related activity on one window andsome command line application on another window. I was hoping Sikuli would beable to do this easily. Are there any other ways like use another tool within Sikulithat can achieve this better?

> To: <email address hidden>
> From: <email address hidden>
> Subject: Re: [Question #264175]: What is the best way to verify the output of the run() command?
> Date: Thu, 26 Mar 2015 10:06:50 +0000
>
> Your question #264175 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/264175
>
> Status: Open => Answered
>
> RaiMan proposed the following answer:
> Using Sikuli features for that is overkill, since you would need the
> not very reliable OCR feature.
>
> simply pipe the command output to a file and just process it.
>
> … or from inside a script use:
> result = run("someCommand parm1 parm2")
> print result
>
> result contains the textual output that the command produced on stdout
> AND stderror
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/sikuli/+question/264175/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/sikuli/+question/264175
>
> You received this question notification because you asked the question.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

I do not understand, what should be such complicated about that.

in the script where you access the browser window, just issue the run(…) and textually process, what you get back (see #1).

Fiddling around with a command line window is far more complicated than this.

Revision history for this message
Hitesh Shah (hitesh-shah) said :
#4

My question is for a command line window.If I issue a command:
result = run("someCommand parm1 parm2")
What is the best way to read 3 - 4 words out of a 10 line output provided by the run command?
Thanks Much.
-Hitesh
> To: <email address hidden>
> From: <email address hidden>
> Subject: Re: [Question #264175]: What is the best way to verify the output of the run() command?
> Date: Thu, 26 Mar 2015 16:01:43 +0000
>
> Your question #264175 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/264175
>
> Status: Open => Answered
>
> RaiMan proposed the following answer:
> I do not understand, what should be such complicated about that.
>
> in the script where you access the browser window, just issue the run(…)
> and textually process, what you get back (see #1).
>
> Fiddling around with a command line window is far more complicated than
> this.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/sikuli/+question/264175/+confirm?answer_id=2
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/sikuli/+question/264175
>
> You received this question notification because you asked the question.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#5

It is really hard to understand your questions, since things you are saying are not fitting together:

-- My question is for a command line window

-- If I issue a command: result = run("someCommand parm1 parm2")

the run() feature has nothing to do with a command window.
You use the run() internally in a script, to create a subprocess, that runs the given command and returns the output of stdout and eventually stderror textually with the return value (in this case it is available in the variable result)

example

# test.sikuli
result = run("dir")
print result

Revision history for this message
Hitesh Shah (hitesh-shah) said :
#6

Thanks Raiman! Problem Solved.