469,602 Members | 1,818 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Jython run scripts problem (2.2.0a0 on Mac OSX 10.3.8)

I installed darwinports and did a "sudo port install jython"

-------------------------

scott$ which jython
/opt/local/bin/jython

-------------------------

Jython works in interactive mode as shown below:

-------------------------

pyprogs$ cd hotbits/
hotbits$ ls
flips50.py jythoninstall.py randomX randomflip.py
hotbits$ jython
Jython 2.2a0 on java1.4.2_05 (JIT: null)
# Truly random (radioactive decay triggered) coin flip
from randomX import randomHotBits
r = randomHotBits()
if r.nextByte() < 0: .... print 'tails'
.... else:
.... print 'heads'
....
tails

--------------------------

Jython *doesn't* work if I save the above as a script and try to run it.
It refuses to run the script and simply starts up in interactive mode:

---------------------------

hotbits$ jython randomflip.py
Jython 2.2a0 on java1.4.2_05 (JIT: null)


---------------------------

Question:
How can I run scripts as expected (outside interactive mode)?

Thanks in advance.
Jul 19 '05 #1
1 2120
scott wrote:
I installed darwinports and did a "sudo port install jython"

-------------------------

scott$ which jython
/opt/local/bin/jython

-------------------------

Jython works in interactive mode as shown below:

-------------------------

pyprogs$ cd hotbits/
hotbits$ ls
flips50.py jythoninstall.py randomX randomflip.py
hotbits$ jython
Jython 2.2a0 on java1.4.2_05 (JIT: null)
>>> # Truly random (radioactive decay triggered) coin flip
>>> from randomX import randomHotBits
>>> r = randomHotBits()
>>> if r.nextByte() < 0: ... print 'tails'
... else:
... print 'heads'
...
tails

--------------------------

Jython *doesn't* work if I save the above as a script and try to run it.
It refuses to run the script and simply starts up in interactive mode:

---------------------------

hotbits$ jython randomflip.py
Jython 2.2a0 on java1.4.2_05 (JIT: null) >>>


---------------------------

Question:
How can I run scripts as expected (outside interactive mode)?

Thanks in advance.


Looks as if the jython shell script does not pass your scriptname as
argument to the interpreter class.

Mine (on linux) looks like this:

"/usr/lib/j2se/1.4/jre/bin/java" -Dpython.home="/home/deets/lib/jython-2.1"
-classpath "/home/deets/lib/jython-2.1/jython.jar:$CLASSPATH"
"org.python.util.jython" "$@"

Note the "$@" - that passes all additional arguments.

--
Regards,

Diez B. Roggisch
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by rt lange | last post: by
3 posts views Thread by Dave Benjamin | last post: by
3 posts views Thread by Jim Hargrave | last post: by
reply views Thread by Maurice LING | last post: by
1 post views Thread by techwiz18 | last post: by
1 post views Thread by Gregor Stich | last post: by
1 post views Thread by nmin | last post: by
reply views Thread by holdingbe | last post: by
5 posts views Thread by sarup26 | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.