Pass variable name to run

Asked by Djg

Hi

I want to open a local txt file in notepad via sikuli. The text file's filename is based on date & time.
When I used run('c:\\..\\notepad.exe "c:\\14Aug2011_1123"') i was able to open the file.

Now since the file name is based on date and time i want to pass variable to the function but it considers the variable name as filename.
filename="c:\\14Aug2011_1123"
run('c:\\..\\notepad.exe filename')

Can someone help me to pass a variable name to the function?

thanks!!

Question information

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

run('c:\\..\\notepad.exe' + filename)

or

run('c:\\..\\notepad.exe %s' % filename)

creates the string based on the CONTENT of filename.

tip: use
r"some text that contains \ backslash"
and you do nor teed to double the \

Revision history for this message
Djg (gdeepakjain) said :
#2

Thanks RaiMan for the quick response.
This resolved my issue to open a file via sikuli script.
But now the problem is after opening the file i want to stop the script. I tried to add exit() but it didnt work, only after i close the txt file the script stops.

Is there a way to achieve want i want to do i.e. stop the script once i open the file?

Thanks!!

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

Sorry, it seems, that the run() does not come back, until the called program terminates.

have a look at the subprocess module. It has options to run another program asynchronously.
http://www.jython.org/docs/library/subprocess.html

Revision history for this message
Djg (gdeepakjain) said :
#4

Thanks RaiMan