Hi!

Thanks for your reply.

I heeded your advice and tried fooling around with the stderr. Apparently even 
if i set the classpath through my execution statement i.e :

   command = "java -jar -classpath 
"/var/lib/zope2.8/instance/plone-site/Extensions/ test.jar"
   os.system(command)

it doesn't seem to work. Because even though i have denoted the path to the jar 
file, this python external method requires me to be in the atual working 
directory in order o sucessfully run this command.

What i tried was to write a shell script instead

   #!/bin/bash
   # My shell script
   path='/var/lib/zope2.8/instance/plone-site/Extensions'
   cd $path
   java -jar test.jar


this shell script is executed by my external method :

   command = "home/ewan/myScript"
   os.system(command)

This works perfectly. So now i know it has to do with the physical working 
directory i am in. Simply setting the classpath doesn't work or giving the 
absolute path to the jar file doesn't work either.

i.e : 

   command = "java -jar 
/var/lib/zope2.8/instance/plone-site/Extensions/test.jar"
   os.system(command)

Anyone knows why this is so? and is there any way around this? I find it 
inefficient that i have my DTML calling My Python calling a Shell Script that 
runs an executable. Such a long chain! 

In any case, thanks for you guys' help!

cheers dudes

wan

> -----Original Message-----
> From: [EMAIL PROTECTED]
> Sent: Tue, 13 Feb 2007 21:45:38 +0100
> To: [EMAIL PROTECTED]
> Subject: Re: [Zope-dev] Extrenal method unable to run the os.popen() or
> os.system() commands
> 
> 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
_______________________________________________
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