From: John E. C. <jc...@ve...> - 2001-03-20 05:24:40
|
Brian, I simply forgot about the exec method. And as the article you referred to points out - it is an easy API to misuse. =20 thanks for the excellent advice, example and article,=20 John At 05:06 PM 3/19/01 -0600, Brian Zimmer wrote:=20 > > Here's an interesting article pertaining to Runtime/Process: > =A0 > > <http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html>http://w > ww.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html > =A0 > brian >> >> -----Original Message-----=20 >> From: jyt...@li... >> [mailto:jyt...@li...]On Behalf Of Brian= Zimmer=20 >> Sent: Monday, March 19, 2001 4:42 PM=20 >> To: John E. Conlon; jyt...@li...=20 >> 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 >> =A0Process 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 >> =A0e.append(r) =20 >> =A0r =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:jython-users-adm >> in...@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.=A0 But after experimentation I can not figure out how to call = =20 >> external executables in my underlying system.=A0 =20 >> Have seen comments that the os.system(name) command is not yet implemented. =20 >> =A0Is 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.so >> urceforge.net/lists/listinfo/jython-users=20 > ************************************************************************ John E. Conlon jc...@ve... tel: (770) 886-5470 fax: (770) 888-6894 <http://www.verticon.com/>www.verticon.com ************************************************************************ |