os.system limitations on Windows NT

Georg Mischler schorsch at schorsch.com
Wed Oct 25 07:26:52 EDT 2000


Markus Kohler wrote:
> Hi,
> I trying to execute a command with a large list of arguments.
> When I do os.system("link " + args) the program crashes.
> When I write the arguments to a file (fileName) and use
>
> os.system ("link @" + fileName)
>
> the arguments are truncated at an arbitrary point.
>
> I'm using Python 1.5.2
>
> Anyone knows a workaround/solution for this
> problem ?

os.system() starts a command shell to interpret the arguments
and then pass them to the actual program you told it to call.
Windows shells, such as command.com for Win9x and cmd.com for
NT/w2k, have an arbitrary limit on the lenght of argument lists.
As long as you can't avoid the use either os.system() or
os.popen(), there's no easy way around the problem.

A possible workaround might be to pass some of the arguments
in the form of environment variables (which again have limits
of their own), or just shorten the arguments in some other way.
All those limits are defined in terms of a maximum number of
chararcers, though I don't remember the exact values. Note
that unix shells may have similar limits, but the acceptable
sizes are usually much bigger there.

The "correct" solution would be to use Mark Hammond's win32
extensions to Python, and work with win32process.CreateProcess(),
which doesn't appear to have any of this kind of limitations.


Have fun!

-schorsch

--
Georg Mischler  --  simulations developer  --  schorsch at schorsch.com
+schorsch.com+  --  lighting design tools  --  http://www.schorsch.com/


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list