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

Discussion in 'Python' started by scott, Apr 21, 2005.

  1. scott

    scott Guest

    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.
     
    scott, Apr 21, 2005
    #1
    1. Advertising

  2. 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
     
    Diez B. Roggisch, Apr 21, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David McNab
    Replies:
    0
    Views:
    523
    David McNab
    Apr 9, 2004
  2. Divya Prakash
    Replies:
    0
    Views:
    469
    Divya Prakash
    Dec 19, 2006
  3. Fabio
    Replies:
    5
    Views:
    1,254
    Fabio
    Apr 17, 2011
  4. superN00b
    Replies:
    7
    Views:
    120
    Gene Tani
    Mar 6, 2006
  5. Replies:
    13
    Views:
    585
    Anno Siegel
    Sep 10, 2007
Loading...

Share This Page