[Zope] External Method unable to run Java jar executable using
os.system()
Ridzwan Aminuddin
wanster at inbox.com
Mon Feb 12 10:34:09 EST 2007
Hi,
I'm trying to run an external method that has a line that runs an os.system command to execute a Java .jar executable that simply outputs a text file as well as prints out a string.
I've saved the python script as well as the Java .jar executable in my Extensions folder:
/var/lib/zope2.8/instance/plone-site/Extensions/
Here is my Python script:
def runYahooSearch2(self):
import os
homedir = os.getcwd()
# on my machine homedir is /var/lib/zope2.8/instance/plone-site
command = "java -jar "+ homedir + "/Extensions/test.jar"
whatisread = os.popen(command).read()
print whatisread
This external method is triggered in my DTML code. I've created other external methods before so i know i've done it right.. but the os.system() command for java -jar just doesn't seem to work. I've tried to use other commands such as:
os.popen("ls") and it works perfectly
Its just this java -jar which does not execute at all... I know it doesn't execute at all cos it doesn't output a file or print the string. If i manually type out into the terminal :
java -jar /var/lib/zope2.8/instance/plone-site/Extensions/test.jar
it works perfectly
But using the external method given above just gives me a blank output.
I've also tried popen2:
from popen2 import popen2
outputTGT, inputTGT = popen2(command)
print outputTGT.readline()
and still the jar is simply skipped and not executed.
Does anyone know whats the cause and cure for this problem?... Or anynone knows any other method i can use instead of os.popen os.popen2 and os.system to run this command line statement?... or any way i can catch the exception which is being thrown when the java -jar is attempting to run ( if there is any in the firt place) ?
Anything would be highly appreciated!... Kinda in a fix right now!...
Thanks in advance!
Cheers
Wan
More information about the Zope
mailing list