From: DOUTCH GARETH-G. <Gar...@mo...> - 2007-02-19 16:49:15
|
Here's the java alternative: >From java.lang import Runtime R =3D Runtime.getRuntime() R.exec('"C:/Program Files/Mozilla Firefox/firefox.exe" www.jython.org')=20 Works. But os.system still seems buggy. Gareth -----Original Message----- From: Philipp Walther [mailto:pwa...@pr...]=20 Sent: 19 February 2007 16:31 To: DOUTCH GARETH-GDO003 Subject: RE: [Jython-users] os.system and path names with spaces Gareth, You're correct - looks like we're hitting a bug here? Still you could use the java class System to get better results (TM). -phil=20 > -----Original Message----- > From: jyt...@li... > [mailto:jyt...@li...] On Behalf Of=20 > DOUTCH GARETH-GDO003 > Sent: Monday, February 19, 2007 5:17 PM > To: jyt...@li... > Subject: Re: [Jython-users] os.system and path names with spaces >=20 > Thanks Phil, > I tried your suggestion but still got the same error. (Did it work ok=20 > for you? It works for me in CPython). > This is the full error trace in case anybody might be able to point=20 > out what is going wrong. > (I am running Jython 2.2a1 on java1.6.0 btw). >=20 > >>> os.system('"C:/Program Files/Mozilla Firefox/firefox.exe" > www.jython.org') > Traceback (innermost last): > File "<console>", line 1, in ? > File "C:\jython\Lib\javaos.py", line 228, in system > File "C:\jython\Lib\popen2.py", line 232, in system > File "C:\jython\Lib\popen2.py", line 69, in __init__ > File "C:\jython\Lib\javashell.py", line 61, in execute=20 > java.lang.IllegalArgumentException > at java.lang.ProcessImpl.<init>(Unknown Source) > at java.lang.ProcessImpl.start(Unknown Source) > at java.lang.ProcessBuilder.start(Unknown Source) > at java.lang.Runtime.exec(Unknown Source) > at java.lang.Runtime.exec(Unknown Source) > at > sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown > Source) > at java.lang.reflect.Method.invoke(Unknown Source) > at > org.python.core.PyReflectedFunction.__call__(PyReflectedFuncti on.java:17 > 4) > at org.python.core.PyMethod.__call__(PyMethod.java:93) > at org.python.core.PyObject.__call__(PyObject.java:607) > at javashell$py.execute$4(C:\jython\Lib\javashell.py:61) > at javashell$py.call_function(C:\jython\Lib\javashell.py) > at org.python.core.PyTableCode.call(PyTableCode.java:213) > at org.python.core.PyTableCode.call(PyTableCode.java:426) > at org.python.core.PyTableCode.call(PyTableCode.java:322) > at org.python.core.PyFunction.__call__(PyFunction.java:193) > at org.python.core.PyMethod.__call__(PyMethod.java:93) > at org.python.core.PyObject.__call__(PyObject.java:594) > at popen2$py.__init__$7(C:\jython\Lib\popen2.py:69) > at popen2$py.call_function(C:\jython\Lib\popen2.py) > at org.python.core.PyTableCode.call(PyTableCode.java:213) > at org.python.core.PyTableCode.call(PyTableCode.java:426) > at org.python.core.PyTableCode.call(PyTableCode.java:322) > at org.python.core.PyFunction.__call__(PyFunction.java:193) > at org.python.core.PyInstance.__init__(PyInstance.java:174) > at org.python.core.PyClass.__call__(PyClass.java:293) > at org.python.core.PyObject.__call__(PyObject.java:621) > at popen2$py.system$21(C:\jython\Lib\popen2.py:232) > at popen2$py.call_function(C:\jython\Lib\popen2.py) > at org.python.core.PyTableCode.call(PyTableCode.java:213) > at org.python.core.PyTableCode.call(PyTableCode.java:426) > at org.python.core.PyFunction.__call__(PyFunction.java:187) > at org.python.core.PyObject._callextra(PyObject.java:725) > at javaos$py.system$40(C:\jython\Lib\javaos.py:228) > at javaos$py.call_function(C:\jython\Lib\javaos.py) > at org.python.core.PyTableCode.call(PyTableCode.java:213) > at org.python.core.PyTableCode.call(PyTableCode.java:426) > at org.python.core.PyFunction.__call__(PyFunction.java:187) > at org.python.core.PyMethod.__call__(PyMethod.java:120) > at org.python.core.PyObject.__call__(PyObject.java:594) > at org.python.pycode._pyx43.f$0(<console>:1) > at org.python.pycode._pyx43.call_function(<console>) > at org.python.core.PyTableCode.call(PyTableCode.java:213) > at org.python.core.PyCode.call(PyCode.java:14) > at org.python.core.Py.runCode(Py.java:1182) > at org.python.core.Py.exec(Py.java:1204) > at > org.python.util.PythonInterpreter.exec(PythonInterpreter.java:148) > at > org.python.util.InteractiveInterpreter.runcode(InteractiveInte > rpreter.ja > va:88) > at > org.python.util.InteractiveInterpreter.runsource(InteractiveIn > terpreter. > java:69) > at > org.python.util.InteractiveInterpreter.runsource(InteractiveIn > terpreter. > java:44) > at > org.python.util.InteractiveConsole.push(InteractiveConsole.java:83) > at > org.python.util.InteractiveConsole.interact(InteractiveConsole > .java:62) > at org.python.util.jython.main(jython.java:214) >=20 > java.lang.IllegalArgumentException:=20 > java.lang.IllegalArgumentException >=20 >=20 > Gareth >=20 > -----Original Message----- > From: Philipp Walther [mailto:pwa...@pr...] > Sent: 19 February 2007 16:03 > To: DOUTCH GARETH-GDO003; jyt...@li... > Subject: RE: [Jython-users] os.system and path names with spaces >=20 > Gareth, >=20 > os.system('"C:/Program Files/Mozilla Firefox/firefox.exe" > www.google.com') >=20 > should do the trick. >=20 > Notice the forward slashes and the ' and ". >=20 > Cheers > Phil >=20 > > -----Original Message----- > > From: jyt...@li... > > [mailto:jyt...@li...] On Behalf Of=20 > > DOUTCH GARETH-GDO003 > > Sent: Monday, February 19, 2007 3:47 PM > > To: jyt...@li... > > Subject: [Jython-users] os.system and path names with spaces > >=20 > > Hi there, > > =20 > > I am trying to execute a browser with an url parameter > passed in. For > > an example > > =20 > > os.system("firefox.exe www.jython.org") > > =20 > > is an ideal kind of format, but it requires the user to add > C:\Program >=20 > > Files\Mozilla Firefox\ to their system path first. > > =20 > > This I cannot assume, so am letting the user specify the browser of=20 > > choice (and full path to it) in a config file. > > Therefore when the browser path os read, my script > generates a "browse >=20 > > to this url" command in the following style C:\Program > Files\Mozilla > > Firefox\firefox.exe www.jython.org <http://www.jython.org/> using=20 > > os.system. > > =20 > > os.system("C:\Program Files\Mozilla Firefox\firefox.exe > > www.jython.org") however results in a "windows cannot find > C:\program > > ... " error. > > =20 > > This format: > > "C:\Program Files\Mozilla Firefox\firefox.exe"=20 > > <http://www.jython.> www.jython. <http://www.jython.org> org works=20 > > nicely from the windows run dialog, but doing: > > os.system('"C:\Program Files\Mozilla Firefox\firefox.exe"=20 > > <http://www.jython./> www.jython.org'=20 > > <http://www.jython.org'> ) gives me a=20 > > java.lang.IllegalArgumentException > > =20 > > Can anyone give me a clue? > > =20 > > Gareth > >=20 > > _______________________________________________________ > >=20 > > Gareth Doutch > > System Test Engineer > > Motorola point to point fixed wireless solutions group > >=20 > > gar...@mo... <mailto:gar...@mo...> > >=20 > > +44 1364 655 581 tel > > +44 1364 654625 fax > >=20 > > Unit A1 Linhay Business Park, > > Eastern Road, > > Ashburton, > > Devon, TQ13 7UP > >=20 > > www.motorola.com/ptp > > _______________________________________________________ > >=20 > > =20 > >=20 >=20 > -------------------------------------------------------------- > ----------- > Take Surveys. Earn Cash. Influence the Future of IT Join=20 > SourceForge.net's Techsay panel and you'll get the chance to share=20 > your opinions on IT & business topics through brief surveys-and earn=20 > cash = http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge &CID=3DDEVDEV > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users >=20 |