I am using a command line software for which I need to input a lot of arguments. Something like

./exec -A argA -B argB -C argC ...

There are so many arguments that I get the error message

Error: Command line too long (302110 >= 130592)

One solution would be to modify the software so that it reads arguments from a file. However, I don't have access to the source code.

Is there a way around this problem?

FYI, I am on Mac OS X 10.11.3 and use Terminal 2.6.1 (361.1)

  • getconf ARG_MAX -the maximum characters allowed by the kernel.
    – fd0
    Sep 22 '16 at 17:50
  • interestingly getconf ARG_MAX returns 262144 which is almost twice as much as 130592 (but still lower than 302110 ).
    – Remi.b
    Sep 22 '16 at 17:57

Put the arguments in a file such as -A argA -B argB -C argC … (excluding the binary), then run:

cat /path/to/file | xargs ./exec
  • Thanks a lot for your answer. I had some trouble while investigating the application of your solution to my specific issue (even though that sounds super simple) and so I asked this question where the first answer seems to say that cat /path/to/file | xargs ./exec cannot be a solution anyway.
    – Remi.b
    Sep 22 '16 at 21:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .