From: Kevin M. <qk...@lm...> - 2001-07-11 08:11:48
|
The solution is a bit more complicated it seems. The following works well. from java.io import * from java.lang import * proc = Runtime.getRuntime().exec("ls -la") stdin = proc.getInputStream() isr = InputStreamReader(stdin) br=BufferedReader(isr) line = br.readLine() while line != None : print(line) line = br.readLine() I got some help from this resource: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html Comments? On Tue, 10 Jul 2001, D-Man wrote: > On Tue, Jul 10, 2001 at 03:44:54PM +0200, Kevin McNamee wrote: > | OK, this works, but it just returns '0'. I guess this the return code from > | the 'ls -al' command. Where is the actual output? > > Yep. That means that the command completed successfully (at least > that's the convention on *nix). > > See > http://java.sun.com/products/jdk/1.2/docs/api/java/lang/Process.html. > java.lang.Runtime.exec returns a java.lang.Process object to you. > That Process object has methods > > getOutputStream() > getInputStream() > getErrorStream() > exitValue() > > You are looking to getOutputStream from the Process. The waitFor > method returns the exitValue. > > HTH, > -D > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-users > _________________________________________________ Name/Title : Kevin McNamee, Software Consultant Phone : +46 13 32 1165 E-Mail : kev...@er... |