|
From: Alec C. <ale...@me...> - 2003-05-01 05:01:29
|
G'Day
Jython 2.1 on Windows 2000 SP3. JDK 1.4.1_1
I am trying to execute a command from within a Jython script and
failing. The snippet below shows the problem I am seeing. I have tried
various different approaches and failed. The only thing I can think of
is that the Java security manager is stopping this perhaps??? How would
I find out or fix it?
Many thanks
>>> from java.util import Random
>>> r = Random()
>>> r.nextInt()
1416976808
>>> from java.lang import Runtime
>>> java.lang.Runtime.getRuntime().exec("cmd.exe /cecho hello")
Traceback (innermost last):
File "<console>", line 1, in ?
NameError: java
--
Alec Clews, Consultant, Merant, Australia
<alec dot clews at merant dot com>
Voice +61-(3)9522-4441 http://merant.com/
|
|
From: Oti <oh...@ya...> - 2003-05-01 05:10:02
|
[ Alec Clews ]
> >>> from java.util import Random
> >>> r = Random()
> >>> r.nextInt()
> 1416976808
> >>> from java.lang import Runtime
> >>> java.lang.Runtime.getRuntime().exec("cmd.exe /cecho hello")
> Traceback (innermost last):
> File "<console>", line 1, in ?
> NameError: java
[infra|pwe] > jython
Jython 2.1 on java1.4.1_02 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> from java.lang import Runtime
>>> Runtime.getRuntime().exec("cmd.exe /cecho hello")
java.lang.Win32Process@9446e4
>>>
So if you say:
process = Runtime.getRuntime().exec("cmd.exe /cecho hello")
you can grab the output of the process.
On the other hand, os.system() maybe already does it for you:
>>> import os
>>> os.system( "echo hello" )
hello
0
>>>
Best wishes,
Oti.
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
|
|
From: Alec C. <ale...@me...> - 2003-05-01 05:18:35
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body>
Oti,<br>
<br>
Many thanks for the help. After you pointed it out it was obvious, bit
embarrassed I did not spot that :-)<br>
<br>
One thing that surprised me was that os.system worked -- I understood
from the Jython web site that os did not work unless you download some
special version implemented using JNI<br>
<br>
<br>
Oti wrote:<br>
<blockquote type="cite"
cite="mid...@we...">
<pre wrap="">[ Alec Clews ]
</pre>
<blockquote type="cite">
<pre wrap=""> >>> from java.util import Random
>>> r = Random()
>>> r.nextInt()
1416976808
>>> from java.lang import Runtime
>>> java.lang.Runtime.getRuntime().exec("cmd.exe /cecho hello")
Traceback (innermost last):
File "<console>", line 1, in ?
NameError: java
</pre>
</blockquote>
<pre wrap=""><!---->
[infra|pwe] > jython
Jython 2.1 on java1.4.1_02 (JIT: null)
Type "copyright", "credits" or "license" for more information.
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">from java.lang import Runtime
Runtime.getRuntime().exec("cmd.exe /cecho hello")
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap=""><!---->java.lang.Win32Process@9446e4
</pre>
<pre wrap=""><!---->
So if you say:
process = Runtime.getRuntime().exec("cmd.exe /cecho hello")
you can grab the output of the process.
On the other hand, os.system() maybe already does it for you:
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">import os
os.system( "echo hello" )
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap=""><!---->hello
0
</pre>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Alec Clews, Consultant, Merant, Australia
<alec dot clews at merant dot com>
Voice +61-(3)9522-4441 <a class="moz-txt-link-freetext" href="http://merant.com/">http://merant.com/</a>
</pre>
</body>
</html>
|
|
From: Oti <oh...@ya...> - 2003-05-01 05:26:26
|
[ Alec Clews ] > One thing that surprised me was that os.system worked -- I > understoodfrom the Jython web site that os did not work unless you > download somespecial version implemented using JNI Not everything from the os module is working like in CPython, but quite a bit ! Oti. __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com |
|
From: Don C. <dco...@ch...> - 2003-05-01 05:35:00
|
try >>> Runtime.getRuntime().exec("cmd.exe /cecho hello")
On Thu, 2003-05-01 at 01:01, Alec Clews wrote:
> G'Day
>
> Jython 2.1 on Windows 2000 SP3. JDK 1.4.1_1
>
> I am trying to execute a command from within a Jython script and
> failing. The snippet below shows the problem I am seeing. I have tried
> various different approaches and failed. The only thing I can think of
> is that the Java security manager is stopping this perhaps??? How would
> I find out or fix it?
>
> Many thanks
>
>
>
> >>> from java.util import Random
> >>> r = Random()
> >>> r.nextInt()
> 1416976808
> >>> from java.lang import Runtime
> >>> java.lang.Runtime.getRuntime().exec("cmd.exe /cecho hello")
> Traceback (innermost last):
> File "<console>", line 1, in ?
> NameError: java
>
>
>
>
|
|
From: Jingzhao Ou <ja...@ya...> - 2003-05-01 07:07:59
|
I am using WindowsXP. I am using jython CVS version on Cygwin. I got the
following. Even though there is no error message, there is nothing happening
either. Any thing wrong? Thanks!
Best regards,
Jingzhao
=================================================================
$ jython
Jython 2.1+ on java1.4.0_01-ea (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> from java.lang import Runtime
>>> Runtime.getRuntime().exec("cmd.exe /cecho hello")
java.lang.Win32Process@dc4cd9
>>> Runtime.getRuntime().exec("cmd.exe")
java.lang.Win32Process@c6b8b0
>>> Runtime.getRuntime().exec("dir")
java.lang.Win32Process@baf4ae
>>> print Runtime.getRuntime().exec("dir")
java.lang.Win32Process@3e6f83
>>>
==================================================================
--- Don Coleman <dco...@ch...> wrote:
> try >>> Runtime.getRuntime().exec("cmd.exe /cecho hello")
>
> On Thu, 2003-05-01 at 01:01, Alec Clews wrote:
> > G'Day
> >
> > Jython 2.1 on Windows 2000 SP3. JDK 1.4.1_1
> >
> > I am trying to execute a command from within a Jython script and
> > failing. The snippet below shows the problem I am seeing. I have tried
> > various different approaches and failed. The only thing I can think of
> > is that the Java security manager is stopping this perhaps??? How would
> > I find out or fix it?
> >
> > Many thanks
> >
> >
> >
> > >>> from java.util import Random
> > >>> r = Random()
> > >>> r.nextInt()
> > 1416976808
> > >>> from java.lang import Runtime
> > >>> java.lang.Runtime.getRuntime().exec("cmd.exe /cecho hello")
> > Traceback (innermost last):
> > File "<console>", line 1, in ?
> > NameError: java
> >
> >
> >
> >
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Jython-users mailing list
> Jyt...@li...
> https://lists.sourceforge.net/lists/listinfo/jython-users
|
|
From: Alec C. <ale...@me...> - 2003-05-01 07:23:08
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body>
<br>
<br>
1) Try using os.system(".....")<br>
<br>
Or if you really want to to use java.lang.runtime<br>
<br>
2) I think you will have to find some way of getting hold of stout
from the process object returned by getRuntime. I had a quick look
inthe Java doc but could see noting obvious<br>
<br>
<br>
<br>
Jingzhao Ou wrote:<br>
<blockquote type="cite"
cite="mid...@we...">
<pre wrap="">I am using WindowsXP. I am using jython CVS version on Cygwin. I got the
following. Even though there is no error message, there is nothing happening
either. Any thing wrong? Thanks!
Best regards,
Jingzhao
=================================================================
$ jython
Jython 2.1+ on java1.4.0_01-ea (JIT: null)
Type "copyright", "credits" or "license" for more information.
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">from java.lang import Runtime
Runtime.getRuntime().exec("cmd.exe /cecho hello")
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap=""><!---->java.lang.Win32Process@dc4cd9
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">Runtime.getRuntime().exec("cmd.exe")
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap=""><!---->java.lang.Win32Process@c6b8b0
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">Runtime.getRuntime().exec("dir")
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap=""><!---->java.lang.Win32Process@baf4ae
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">print Runtime.getRuntime().exec("dir")
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap=""><!---->java.lang.Win32Process@3e6f83
</pre>
<pre wrap=""><!---->==================================================================
--- Don Coleman <a class="moz-txt-link-rfc2396E" href="mailto:dco...@ch..."><dco...@ch...></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">try >>> Runtime.getRuntime().exec("cmd.exe /cecho hello")
On Thu, 2003-05-01 at 01:01, Alec Clews wrote:
</pre>
<blockquote type="cite">
<pre wrap="">G'Day
Jython 2.1 on Windows 2000 SP3. JDK 1.4.1_1
I am trying to execute a command from within a Jython script and
failing. The snippet below shows the problem I am seeing. I have tried
various different approaches and failed. The only thing I can think of
is that the Java security manager is stopping this perhaps??? How would
I find out or fix it?
Many thanks
>>> from java.util import Random
>>> r = Random()
>>> r.nextInt()
1416976808
>>> from java.lang import Runtime
>>> java.lang.Runtime.getRuntime().exec("cmd.exe /cecho hello")
Traceback (innermost last):
File "<console>", line 1, in ?
NameError: java
</pre>
</blockquote>
</blockquote>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Alec Clews, Consultant, Merant, Australia
<alec dot clews at merant dot com>
Voice +61-(3)9522-4441 <a class="moz-txt-link-freetext" href="http://merant.com/">http://merant.com/</a>
</pre>
</body>
</html>
|