2

Using rscript inside a bash script

I am passing the content of text files has arguments. to rscript

"$SCRIPTS/myscript.R" "$filecontent"

I get the following when file have +- over 4000 row

/usr/bin/Rscript: Argument list too long

Any way I can increase the length of accepted argument so I can pass large files?

  • 4
    Instead of passing the the file contents, why not pass the file name so the script can open it itself? Or possibly stream the contents to the script via stdin? – MrFlick Jul 09 '14 at 16:06

1 Answers1

2

What @MrFlick said is correct - you should change the way the arguments are passed to your script. However, if you still want to try to do it your way, then I recommend reading the following article:

"Argument list too long": Beyond Arguments and Limitations

The "Argument list too long" error, which occurs anytime a user feeds too many arguments to a single command, leaves the user to fend for oneself, since all regular system commands (ls *, cp *, rm *, etc...) are subject to the same limitation. This article will focus on identifying four different workaround solutions to this problem, each method using varying degrees of complexity to solve different potential problems.

Also, this Unix&Linux thread can help:

“Argument list too long”: How do I deal with it, without changing my command?

Community
  • 1
  • 1
jimm-cl
  • 5,124
  • 2
  • 25
  • 27
  • Tried the option in _How do I deal with it, without changing my command?_ `setting ulimit -s unlimited` still got the "Argument list too long" error turned to an other solution involving not using arguments. Has suggested. – user3641949 Jul 09 '14 at 22:45