From: DOUTCH GARETH-G. <Gar...@mo...> - 2007-02-19 16:17:31
|
Thanks Phil, I tried your suggestion but still got the same error. (Did it work ok for you? It works for me in CPython).=20 This is the full error trace in case anybody might be able to point out what is going wrong. (I am running Jython 2.2a1 on java1.6.0 btw). >>> 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 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__(PyReflectedFunction.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(InteractiveInterpreter.ja va:88) at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter. java:69) at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter. 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) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException=20 Gareth -----Original Message----- From: Philipp Walther [mailto:pwa...@pr...]=20 Sent: 19 February 2007 16:03 To: DOUTCH GARETH-GDO003; jyt...@li... Subject: RE: [Jython-users] os.system and path names with spaces Gareth, os.system('"C:/Program Files/Mozilla Firefox/firefox.exe" www.google.com') should do the trick. Notice the forward slashes and the ' and ". Cheers Phil > -----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=20 > 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 > 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 > to this url" command in the following style C:\Program Files\Mozilla=20 > 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=20 > ... " 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 |