[Zope-dev] Extrenal method unable to run the os.popen() or
os.system() commands
Dieter Maurer
dieter at handshake.de
Tue Feb 13 15:45:38 EST 2007
Ridzwan Aminuddin wrote at 2007-2-12 19:41 -0800:
> ...
>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
Thus, you have found out that the problem is not with "ExternalMethod"
or "popen" in principle but with "java" calls done this way.
I would expect that "java" cannot be executed (maybe, because the
"PATH" variable is different when run from Zope and "java" is not
on this "PATH") or that "java" is executed but dislikes something
in the environment.
In both cases, I would expect some problem message on "stderr".
Thus, I (in your place) would check how I could capture the "stderr" of
the "popen" process and carefully look at it.
One possibility would be to redirect "stderr" in the "popen" command
itself ("... >> /tmp/java.stderr").
In principle, it is possible to start "java" from an "ExternalMethod"
with "os.system" and friends.
We do this all the time.
--
Dieter
More information about the Zope-Dev
mailing list