How to change size of command line in unix

Hi,

I'm trying to execute my program from $prompt by passing many parameters which is more than 300 charecters in line but unix not accepting those many charecters, could some one help me how to increase the size?

thanks

what is the error that you get?

one alternative you can try is: keep your program name along with all arguements in a file and run that file (like a shell script)

Can you replace some of the input with variables.

a="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
b="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
proc $a $b

or create a file with the input in it.
echo $a >temp.txt
echo $b >>temp.txt
proc <temp.txt

You should try this solution too :

  • create a file (named param.txt here) and put your 2 parameters inside (on 2 lines)
  • execute your program 'prog.sh' :
    prog.sh `cat param.txt | head -1` `cat param.txt | tail -1`

Thanks for the reply, actually I'm looking for the configuration change, any idea where to change this to increase size of command line?

Krishna,
As far I know, in POSIX UNIX, the value which control the arg length is _POSIX_ARG_MAX, whose max value can be found in /usr/include/limits.h which is 4096. In HP-UX 11 and above, this value is 2048000

Snippet from Man page of limits:

_POSIX_ARG_MAX         4096  /* max length of arguments to exec */

ARG_MAX
    Maximum length of argument to the exec functions including
 environment data. Minimum Acceptable Value: _POSIX_ARG_MAX

I am not sure how to change it, but I think you will need the kernel source and would have to change it and recompile the kernel to take effect.

Also remember that the env variables also are included in this 4096.

-GGR

Could also be this line from the same file (limits.h)
#define MAX_INPUT 256 /* max size of a char input buffer */

Generally you cannot increase the size since most system utilities have LINE_MAX or POSIX2_LINE_MAX hard wired in at compile time and so cannot be charged.

POSIX2_LINE_MAX: Unless otherwise noted, the maximum length, in bytes, of a utility's input line (either standard input or another file), when the utility is described as processing text files. The length includes room for the trailing <newline>. Value: 2048

You can use getconf or sysconf(_SC_LINE_MAX) to return the actual value.