using os.execl to call a java application

Louis Luangkesorn lluang at northwestern.edu
Sun Mar 24 00:40:57 EST 2002


Hello:

I am trying to use Python to call a Java application with parameters and 
I am trying to use os.execl to do this.  When I am at the command line, 
the following works:

C:\docs\ibmmodelswitch>c:\jdk1.3\bin\java depmmk1 22.0 20.0 10.0 0.0 0.0 
20 20 5 5 5 
5                                                                         
0.009888807988285522

But when I try to call this from Python using os.execl, I get

  File "C:\docs\gmcode\prob4.py", line 74, in findrqsim
    os.path('c:\\docs\\ibmmodelswitch')
TypeError: object of type 'module' is not callable
 >>>
Lines 73 and 74 are as follows:
os.path('c:\\docs\\ibmmodelswitch')
rab[i,j] = 
os.execl('c:\\jdk1.3\\bin\\java','depmmk1',`itemmu[0]`,`itemmu[1]`,`itemlambda[0]`,`itemlambda[1]`,`itemlambda[2]`,`itemn[0]`,`itemn[1]`,`itemQ[0]`,`itemQ[1]`,`itemreorder[0]`,`itemreorder[1]`)

I've tried to use the full path for 'depmmk1' in the os.execl() call. 
 I've tried using one '\'\ for the directory, I've also tried to have 
the second arguement 'depmmk1.class'.  The following also fails:

            os.path('c:\\docs\\ibmmodelswitch')
            rab[i,j] = os.execl('c:\\jdk1.3\\bin\\java','depmmk1')

Anyone help?  Or is there an even better way to do this?

The next question I'm going to have is how to get a result from my Java 
application into Python.  I can use a text file write/read, but if there 
is a more elegant way of doing this I'd appreciate hearing about it. 
 Thank you much.

Louis
By the way, what I really want to do is this:
            os.path('c:\\docs\\ibmmodelswitch')
            rab[i,j] = 
os.execl('c:\\jdk1.3\\bin\\java','depmmk1',`itemmu[0]`,`itemmu[1]`,`itemlambda[0]`,`itemlambda[1]`,`itemlambda[2]`,`itemn[0]`,`itemn[1]`,`itemQ[0]`,`itemQ[1]`,`itemreorder[0]`,`itemreorder[1]`)

Which gives the same error.

Louis

-- 
K Louis Luangkesorn
lluang at northwestern.edu  http://pubweb.nwu.edu/~kll560  PGP:0xF3E2D362

Whatsoever things are true, ... honest, ... just, ... pure, ... lovely, ... of good report; if there be any virtue, and if there be any praise, think on these things.  
     - motto - Northwestern University





More information about the Python-list mailing list