Issue484181

classification
Title: command line args in dos
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: bckfnn Nosy List: bckfnn, becke
Priority: normal Keywords:

Created on 2001-11-21.14:30:56 by becke, last changed 2001-11-26.08:39:46 by bckfnn.

Files
File name Uploaded Description Edit Remove
jython.bat becke, 2001-11-22.05:28:57 modified jython.bat
Messages
msg473 (view) Author: Michael Becke (becke) Date: 2001-11-21.14:30:56
The batch file jython.bat currently only supports
passing up to 9 command line arguments to jython. 
Though this is a fair number, it is possible to do an
unlimited number.  Here's a little batch that should
accomplish this:

set ARGS=

if "%1" == "" goto done
set ARGS="%1"

:loop
shift
if   "%1"==""  goto  DONE
set ARGS=%ARGS% "%1"
goto loop
:done

"C:\Program Files\JavaSoft\JRE\1.3.1\bin\java.exe"
"-Dpython.home=C:\Java\jython-2.0" -classpath
"C:\Java\jython-2.0\jython.jar;%CLASSPATH%"
org.python.util.jython %ARGS%


Mike
msg474 (view) Author: Finn Bock (bckfnn) Date: 2001-11-21.15:18:09
Logged In: YES 
user_id=4201

Unfortunately that solution will destroy quoted arguments 
with spaces on win2k. The script:

  import sys; print sys

and the command line:

  jython x.py "abc def" "123"

will output a different result with the argument loop.

   ['x.py', 'abc def', '123']

vs

   ['x.py', 'abc', 'def', '123']
msg475 (view) Author: Michael Becke (becke) Date: 2001-11-21.18:00:42
Logged In: YES 
user_id=219481

You are correct.  In looking for a fix for this I discovered
that %* contains all command line arguments.  Changing to
the following seems to work:

"C:\Program Files\JavaSoft\JRE\1.3.1\bin\java.exe"
"-Dpython.home=C:\Java\jython" -classpath
"C:\Java\jython\jython.jar;%CLASSPATH%"
org.python.util.jython %*

Mike
msg476 (view) Author: Finn Bock (bckfnn) Date: 2001-11-21.18:46:21
Logged In: YES 
user_id=4201

On all versions of windows? I doubt it. From the startup 
script of ant-1.3:

   rem On NT/2K grab all arguments at once
   set ANT_CMD_LINE_ARGS=%*
   goto doneStart

   :win9xStart
   rem Slurp the command line arguments.  This loop allows
   rem for an unlimited number
   rem agruments (up to the command line limit, anyway).
   ...
      
It's tricky stuff.
msg477 (view) Author: Michael Becke (becke) Date: 2001-11-22.05:28:57
Logged In: YES 
user_id=219481

You could be right, I don't have a Win9x machine to test on.

After some more fiddling I think I have a way to create a
string from the original command line args that preserves
quoted items.  I've attached my modified jython.bat.  When
running the simple script you outlined earlier with the new
jython.bat file things seem to work.

Mike
msg478 (view) Author: Finn Bock (bckfnn) Date: 2001-11-26.08:39:46
Logged In: YES 
user_id=4201

Thank you for the work you have done with this.
History
Date User Action Args
2001-11-21 14:30:56beckecreate