----- Original Message ----- From: "Ridzwan Aminuddin" <[EMAIL PROTECTED]>
To: "Dieter Maurer" <[EMAIL PROTECTED]>; <zope-dev@zope.org>
Cc: <zope-dev@zope.org>
Sent: Monday, February 12, 2007 10:41 PM
Subject: Re: [Zope-dev] Extrenal method unable to run the os.popen() oros.system() commands


Hi!

Thanks for your reply. Honestly, I'm not sure why the external method is skipped. I've tried several methods to debug and changed my python code to see the effects.


I wrote another Java Jar. called test.jar that when executed prints out a line to stdout and creates a text file to the same directory that the jar is placed in. I placed this jar file as well as the external method python file in the Extensions directory /var/lib/zope2.8/instance/plone-site/Extensions

This is how the external method looks like:

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 "ls" which works perfectly:

command = "ls"
whatisread = os.popen(command).read()
print whatisread

This will sucessfully list out all the files/folders in the working directory.

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, it prints out the string as well as outputs a text file into the directory the jar file is in.
But using the external method given above just gives me a blank output.

I've also tried popen2:

For executing system commands I have used "commands.getstatusoutput(...)" in external methods with no problems.


Jonathan

_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Reply via email to