|
RE: Re: Question regarding passing external commandline arguements: msg#00011lang.jython.user
Thanks Jeff . I did the following inside my script and it works. test= java.lang.System.getProperty('env') print test loadpath= 'c:/beacases/627825/wlstoffline9' +'/'+test print loadpath loadProperties(loadpath) One more final question I have the following inside the python script cmo.setURL(driverurl) props = makePropertiesObject("user=dbusername") If user is hardcoded then it works, if it is trying to pick from a properties file it doesn't work Have a nice day. Thanks srikrishna -----Original Message----- From: Jeff Emanuel [mailto:jemanuel@xxxxxxxx] Sent: Monday, March 13, 2006 10:59 AM To: Parthasarathy, Srikrishna - Information Technology <Srikrishna_Parthasarathy@xxxxxxxxxxx> Cc: jython-users@xxxxxxxxxxxxxxxxxxxxx Subject: Re: [Jython-users] Re: Question regarding passing external commandline arguements If you want to access the values set with -D from jython, as in your original query, just use java.lang.System.getProperty. Srikrishna_Parthasarathy@xxxxxxxxxxx wrote: > Thanks for your response. WLST is a wrapper around Jython . I don't know on how to use for an existing python script your suggestion. Can you please explain ? Meanwhile I have asked BEA what arguments I can pass to their python scripts. > > -----Original Message----- > From: jython-users-admin@xxxxxxxxxxxxxxxxxxxxx [mailto:jython-users-admin@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of Dave Kuhlman > Sent: Thursday, March 09, 2006 7:13 PM > To: jython-users@xxxxxxxxxxxxxxxxxxxxx > Subject: [Jython-users] Re: Question regarding passing external commandline arguements > > <Srikrishna_Parthasarathy <at> timeinc.com> writes: > >>I am new to Jython . I have the following .py file . This >>has been created based on BEA's doc. I used to create a weblogic domain. >>I want the py script to be more generic. I run now using >> >> >> >>Java weblogic.WLST filename.py > > > Why not pass in your arguments as command line flags and command line arguments? > You can use the getopt module, which is available to Jython, to parse flags and > arguments. > > Would that solve your problem? If so, below is a sample script taken from some > boiler plate that I use. > > You can run this script with something like the following: > > $ jython test_clargs.py --myflag=somevalue myargument > > or: > > $ jython test_clargs.py -m somevalue myargument > > Dave > > ============================================================= > > # test_clargs.py > > import sys > import getopt > > def test(flag, arg1): > print 'flag: "%s"' % (flag, ) > print 'arg: "%s"' % (arg1, ) > > USAGE_TEXT = """ > Usage: > python test_clargs.py [options] > Options: > -h, --help Display this help message. > Example: > python test_clargs.py --myflag=somevalue arg1 > """ > > def usage(): > print USAGE_TEXT > sys.exit(-1) > > def main(): > args = sys.argv[1:] > try: > opts, args = getopt.getopt(args, 'hm:', ['help', 'myflag=']) > except: > usage() > myflag = None > for opt, val in opts: > if opt in ('-h', '--help'): > usage() > elif opt in ('-m', '--myflag'): > myflag = val > if len(args) != 1: > usage() > test(myflag, args[0]) > > if __name__ == '__main__': > main() > > ============================================================= > > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Jython-users mailing list > Jython-users@xxxxxxxxxxxxxxxxxxxxx > https://lists.sourceforge.net/lists/listinfo/jython-users > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642 > _______________________________________________ > Jython-users mailing list > Jython-users@xxxxxxxxxxxxxxxxxxxxx > https://lists.sourceforge.net/lists/listinfo/jython-users ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: Re: Question regarding passing external commandline arguements, Srikrishna_Parthasarathy |
|---|---|
| Next by Date: | Dynamic Jython Web programming using MyOODB ( Object-Oriented Database ), Tom Hazel |
| Previous by Thread: | RE: Re: Question regarding passing external commandline arguements, Srikrishna_Parthasarathy |
| Next by Thread: | Special method names problem?, Eugene Rosenzweig |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |