← Back to team overview

sikuli-driver team mailing list archive

[Question #277479]: SiKuli Unable to Pass Arguments via Sys.arg

 

New question #277479 on Sikuli:
https://answers.launchpad.net/sikuli/+question/277479

I am trying to pass arguments via commandline 

I can launch Sikuli scripts to run via
SiKuli Unable to Pass Arguments

C:\pathtosikuli\runsikulix.cmd -r C:\Sikuli\scripts\mysikulscript.sikuli -w arg1 arg2

alternatively you might use:
java -jar C:\pathtosikuli\sikulix.jar -r C:\Sikuli\scripts\mysikulscript.sikuli  -w arg1 arg2

Scripts loads and runs file but after complete execution I cannot pass arg1 and arg2.
I tried passing arguments via:

import sys

for arg in sys.argv:
    print arg

this prints only:
C:\Sikuli\scripts\mysikulscript.sikuli 

do I need to be able to pass in arg1 and arg2

I also tried:

import getopt
from optparse import optionparser
parser = optionparser()
parser.add_option("-w", "--foo", help="set foo option")
parser.add_option("-b", "--bar", help="set bar option")
(options, args) = parser.parse_args()
print "options: %s" % options
print "args: %s" % args

but i am getting import error:
cannot import name optionparser


I also tried

import getopt, sys

try:
    opts, args = getopt.getopt(sys.argv[1:], “ho:v”, [“help”, “output=”])
except getopt.GetoptError, err:
    # print help information and exit: print str(err) # will print something like “option -a not recognized” usage() sys.exit(2)

output = None verbose = False for o, a in opts:

    if o == “-v”:
        verbose = True
    elif o in (“-h”, “–help”):
        usage() sys.exit()
    elif w in (“-w”, “–output”):
        output = a
    else:
        assert False, “unhandled option”

Still does not work.




-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.