views:

182

answers:

1

Does anyone know a portable way for Python to determine a system's maximum command line length? The program I'm working on builds a command and feeds it to subprocess. For systems with smaller command line length maximums, it is possible that the command will be too long. If I can detect that, the command can be broken up to avoid exceeding the maximum length, but I've not found a (portable) way to determine the maximum.

+3  A: 
James Antill
Now why couldn't I find that? Thanks! Alas, it doesn't work on my Windows system, but that may be okay. However, I expect I'll need to make it work on a Mac, even though I don't have access to one. Do you know if sysconf is available on OS X?
PTBNL
Should work fine on OS X.
Alex Martelli
The docs state this is for Unix only (both Mac and Unix for <= Python2.5). Also the dictionary lookup is not required, `os.sysconf('SC_ARG_MAX')` also works.
mhawke