[Zope-dev] Extrenal method unable to run the os.popen() or os.system() commands

Dieter Maurer dieter at handshake.de
Mon Feb 12 15:24:24 EST 2007


Ridzwan Aminuddin wrote at 2007-2-9 17:53 -0800:
>Oh yes, i forgot to mention that in my code i did use the absolute paths to my java .jar file as you can see i my code below, the absolute path to the Extensions directory is in the variable homedir. I also set my classpath to point to the folder just in case..

Relative paths do work -- but, they are (as always) relative to
the current working directory.
And unless you (or some buggy extension) have changed it, the
current working directory will be Zope's instance home.

> ...
>homedir = os.getcwd()
>homedir = homedir + "/Extensions"
>
>command = "cd "+homedir
>os.popen(command)

The "popen" above still has no effect. You should remove
code without effect as it clutters the source.

>command = "java -jar "+ '"' + homedir + "/" + "ActiveLearningTools.jar" + '" ' +
>"prepArticles >> test.txt"
>os.popen(command)

This will look for "ActiveLearningTools.jar" in
"<instancehome>/Extensions". But the output file "test.txt"
will be put into "<instancehome>" (as this name is still relative).


Have you already told us in what way your "ExternalMethod" fails?
Do you get an exception? Or is simply the output file not produced?
Or does the output file remain empty?



-- 
Dieter


More information about the Zope-Dev mailing list