From: Brian Z. <bz...@ig...> - 2001-03-19 23:04:12
|
Here's an interesting article pertaining to Runtime/Process: =20 http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html <http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html>=20 =20 brian -----Original Message----- From: jyt...@li... [mailto:jyt...@li...]On Behalf Of Brian Zimmer Sent: Monday, March 19, 2001 4:42 PM To: John E. Conlon; jyt...@li... Subject: RE: [Jython-users] How to call external commands Here's an extremely simple example (by no means production, but could get you on your way):=20 """=20 Process the command.=20 """=20 from java.lang import Runtime=20 from java.io import BufferedInputStream=20 p =3D Runtime.getRuntime().exec("ls")=20 #p.waitFor()=20 stream =3D BufferedInputStream(p.getInputStream())=20 e =3D []=20 r =3D stream.read()=20 while r !=3D -1:=20 e.append(r)=20 r =3D stream.read()=20 print "".join(map(chr, e))=20 Running it produces:=20 D:\home\development\python>jython process.py=20 HTTPSession$py.class=20 HTTPSession.py=20 __init__.py=20 a5.py=20 aar.py=20 acl.py=20 aioobe.py=20 ant.py=20 atl.py=20 caps.py=20 cont.py=20 brian=20 -----Original Message-----=20 From: jyt...@li...=20 [ mailto:jyt...@li... <mailto:jyt...@li...> ]On Behalf Of John E.=20 Conlon=20 Sent: Monday, March 19, 2001 4:22 PM=20 To: jyt...@li...=20 Subject: [Jython-users] How to call external commands=20 Hi Jython users,=20 I would like to replace my bat and sh startup scripts with jython py=20 scripts. But after experimentation I can not figure out how to call=20 external executables in my underlying system. =20 Have seen comments that the os.system(name) command is not yet implemented.=20 Is there any other way to launch external programs without the os.system=20 command?=20 thanks for any suggestions,=20 John=20 _______________________________________________=20 Jython-users mailing list=20 Jyt...@li...=20 http://lists.sourceforge.net/lists/listinfo/jython-users <http://lists.sourceforge.net/lists/listinfo/jython-users> =20 |