Capturing value automatically from a Terminal window

Asked by Pritam Biswas

Hi,

I want to perform below steps to fulfill my POC on simulation of an existing process-
1. Create a script that adds and multiplies two numbers
 Output – sum: <#>, product: <#>
2. Specify a set of input number pairs in a file
3. Sikuli reads the file and runs the script with those inputs
4. Sikuli reads result off the screen(Sum & Product) and writes in a output file.

Upto step 3 i've covered, now i'm not able to figure out how i can perform step 4. Any idea will be helpful. My bat produces output like-
echo Sum is: %Sum%
echo Multiplication is: %Multiplication%
Below is what i've done after taking reference from this forum-
import os
noList = []
dir = "E:\Pritam\SikuliXVer2.1.0-SNAPSHOT"
noFile = os.path.join(dir, "Number.txt")
f = open(noFile)
for line in f.readlines():
    id = line.strip()
    print id
    noList.append(id)
    #print(noList)
f.close()

App.open(r'CMD /k start "Sample screen" "E:\Pritam\SikuliXVer2.1.0-SNAPSHOT\SikuliX.sikuli\Sum_two_simulation.bat" ')
for id in noList:
    type("" + id + Key.ENTER)
wait(3)

Question information

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

General advice:
Please work with a stable version (currently 2.0.3).

Version 2.1.0 is under heavy development and not guaranteed to work at any time.

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

As far as I understand, then the result gets visible in the command window.

You might try to use the text features, to read the content of the command window.

Revision history for this message
Pritam Biswas (pritam-b) said :
#3

Thanks Raiman, We're using version 2.0.3 only, just placed that file in an old folder. Will try to read the texts from command window as per suggestion.

Can you help with this problem?

Provide an answer of your own, or ask Pritam Biswas for more information if necessary.

To post a message you must log in.