is perl better?

Discussion in 'Python' started by jon c, Mar 5, 2004.

  1. jon c

    jon c Guest

    well the cammand is

    java -hotspot -showversion ...... -classpath loads of entries
    application-name

    the total string is 6809 characters long.

    I do not know the allowed character length (I am using windows 2000)

    but perl just runs the command fine, whereas python results in

    The following character string is too long:

    .........

    _________________________________________________________________
    Use MSN Messenger to send music and pics to your friends
    http://www.msn.co.uk/messenger
     
    jon c, Mar 5, 2004
    #1
    1. Advertising

  2. jon c

    Peter Hansen Guest

    jon c wrote:
    > well the cammand is
    >
    > java -hotspot -showversion ...... -classpath loads of entries
    > application-name


    Okay, I accept that the string being passed in is very long, and that
    the details aren't relevant here. How about some example code? From
    the Perl one that works, and the Python one that doesn't. There are a
    dozen ways of invoking external programs...

    > the total string is 6809 characters long.


    This is likely far too long for the Windows command line, but perhaps
    2000 is more sophisticated than I would expect...

    > I do not know the allowed character length (I am using windows 2000)
    >
    > but perl just runs the command fine, whereas python results in
    >
    > The following character string is too long:


    Is that the sum total of the error message? Is it coming from Python,
    or from the shell, or what? Sometimes cutting and pasting the actual
    string helps. Unless that's really all there was, other than the string
    itself.

    Without more info, all I can suggest is try using popen instead of
    os.system, but that's just guessing since we don't know you _are_ using
    os.system right now.

    -Peter
     
    Peter Hansen, Mar 5, 2004
    #2
    1. Advertising

  3. Windows command-line length limitation (was Re: is perl better?)

    >> the total string is 6809 characters long.
    >
    > This is likely far too long for the Windows command line, but perhaps
    > 2000 is more sophisticated than I would expect...
    >
    >> I do not know the allowed character length (I am using windows 2000)
    >> but perl just runs the command fine, whereas python results in
    >> The following character string is too long:


    Just to throw in some real numbers, MSDN knowledge base article 830473
    <http://support.microsoft.com/default.aspx?scid=kb;en-us;830473>
    says:

    """
    On computers running Microsoft Windows XP or later, the maximum length
    of the string that you can use at the command prompt is 8191
    characters. On computers running Microsoft Windows 2000 or Windows NT
    4.0, the maximum length of the string that you can use at the command
    prompt is 2047 characters.

    This limitation applies to the command line, individual environment
    variables (such as the PATH variable) that are inherited by other
    processes, and all environment variable expansions. If you use Command
    Prompt to run batch files, this limitation also applies to batch file
    processing.
    """

    Read the article to found out more (but not much more).

    BTW: The workarounds that the article mentions sound more like the old
    MSDOS days than like a modern operating system.
    Ridiculous examples:
    # Use shorter names for folders and files.

    # Reduce the depth of folder trees.

    # Store files in fewer folders so that fewer folders are
    # required in the PATH environment variable.

    Thomas
     
    Thomas Heller, Mar 5, 2004
    #3
  4. jon c wrote:
    > well the cammand is
    >
    > java -hotspot -showversion ...... -classpath loads of entries
    > application-name
    >
    > the total string is 6809 characters long.
    >


    Maybe a workaround would be to use the CLASSPATH environment
    variable instead of the command line -classpath parameter
    (using os.environ from python). Hopefully this would make your
    command line short enough not to hit any hard limit.

    os.environ[ 'CLASSPATH' ] = 'lib1.jar:...:libN.jar'
    os.system ( 'java -hotspot -showversion application-name' )


    Hope this helps,

    Bernard.
     
    =?ISO-8859-1?Q?Bernard_Delm=E9e?=, Mar 5, 2004
    #4
    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. dpackwood
    Replies:
    3
    Views:
    1,872
  2. Peter Bencsik
    Replies:
    2
    Views:
    882
  3. Andrew Thompson
    Replies:
    8
    Views:
    164
    Premshree Pillai
    Jun 7, 2005
  4. Lew
    Replies:
    0
    Views:
    431
  5. Replies:
    2
    Views:
    70
    Mark H Harris
    May 13, 2014
Loading...

Share This Page