Quantcast

Maximum length for a -e argument to Rscript?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Maximum length for a -e argument to Rscript?

Ben Haller-2
  Hi!  I’m attempting to use Rscript to do some automated plotting.  It is working well, except that I seem to be running into a maximum line length issue, and I’m wondering if it is a bug on your end.  Here’s an example of the command I’m trying to run:

/usr/local/bin/Rscript -e '{x <- c(-1.31171, -0.686165, 1.62771, 0.320195, -0.322011, 1.66518, -0.271971, -0.665367, 0.516482, -0.716343, -0.317471, 0.068046, -0.100371, -1.15907, 0.263329, -0.936049, -0.852444, 0.358817, -0.233959, 0.209891, -0.831575, -0.952987, -0.0420206, -1.78527, -0.280584, -0.62353, 1.42597, 0.127994, 0.0751232, 0.896835, -0.319488, 0.897876, 0.18457, 0.779571, -0.0543194, 0.226722, -0.769983, -0.723463, 0.144386, -0.468544, -0.349417, 0.336786, 0.749212, -1.62397, 0.683075, -0.746449, 0.300921, -0.365468, 0.548271, 1.13169, -1.34042, -0.0740572, 1.34986, 0.531771, -0.147157, 0.824894, -1.05816, 1.58867, -0.885764, 1.11912, 0.361512, 1.77985, 0.585099, -1.205, 2.44134, -0.331372, -0.346322, 0.0535267, -1.75089, 0.0773243, -1.07846, -1.29632, 1.0622, 1.34867, 0.199777, 0.197516, 0.574185, 1.06555, -0.885166, -0.788576, -1.46061, -1.54026, 0.690576, -0.88821, 0.343747, -0.100751, -0.865596, -0.128504, 0.222334, -1.18932, -0.555258, -0.557368, 0.219272, 0.298858, 0.848022, 0.142608, 1.10082, -0.348039, 0.0566489, 0.662136, 0.50451, -0.909399, 1.02446, 1.40592, -0.114786, -1.10718, 2.02549, 0.0818607, -1.037, 1.18961, -0.204, 2.83165, -0.959653, -0.393082, -0.463351, 0.914054, 1.14472, -1.32927, 1.25416, 0.372267, 0.410832, 1.04187, 1.22288, 1.27131, 0.0949385, 0.194053, -0.226184, -0.502155, -1.36834, -0.000591861, -0.565903, 1.14099, 1.67811, 0.331709, -0.756879, 0.889596, 0.718098, 0.740242, -0.861818, 0.0332746, 1.01745, 0.584536, -1.14245, -0.444485, -1.34237, 0.660603, 1.16048, -0.898828, 0.965746, -1.16953, -2.33417, 0.591078, -0.364892, 0.0719267, -1.21676, 1.12646, 1.37534, 0.0712832, 1.22889, -0.0110024, 0.248213, -1.12013, -0.525197, -0.352156, -0.317182, -0.89552, 1.53422, -1.36777, 1.52099, 1.18789, -3.15251, 1.24008, -0.564289, -0.515629, -0.0920464, 2.94027, 0.895481, -0.157643, -0.347874, -0.290823, -0.771436, 1.29285, 0.216689, -1.86856, 2.24075, 0.888635, 0.430417, -0.585856, 1.13119, -0.243977, 0.544491, 0.921995, 0.815365, 1.2584, -1.29347, 0.0574579, 0.990557, -1.58657, -0.264373, 0.865893, 0.599298, -0.417531, 0.132897, 1.88597, 1.33112, -0.880904, 0.0762161, 0.0567852, 0.593295, -0.632135, 0.885625, 0.365863, -0.17885, 0.420185, -0.508275, 0.974357, 0.628085, 0.710578, 1.72447, 1.38488, 1.01301, 1.30015, 0.260501, 0.808981, 0.440228, 0.416344, -1.66273, -0.397224, -0.512086, -0.175854, -0.663143, 0.369712, -1.01654, 0.660465, 0.124851, -1.51101, -0.95725, 2.09893, 1.26819, 1.08086, 0.493204, 0.79073, 1.49191, 0.563689, 0.414473, 2.27361, 0.871923, 0.193703, -0.185039, -0.312859, -1.42267, -2.11561, 0.311996, -0.0906527, 1.19139, 1.57502, 1.10587, 0.416333, 2.35374, -1.0531, 0.0450512, 0.979958, 0.398269, 0.0897618, -0.855305, -1.59337, -0.084904, 0.245872, 1.27115, 1.3512, -0.166962, 1.01098, -1.19854, -2.05932, -0.98, 0.704973, 0.694688, 1.20408, -1.12553, 0.770056, 1.01602, 0.295223, -1.18801, 1.51707, 1.1418, -0.148787, 1.28886, 1.23981, 1.67984, 0.0185941, -0.877581, 0.495042, -0.368668, 1.59972, -2.20849, -1.36852, -0.972566, -1.01848, -0.366674, -2.60273, -0.540706, -0.475797, 0.227651, -1.11476, 1.73452, -0.212185, 3.04994, -0.251225, -0.0443482, -0.489125, 0.557936, -0.246389, -0.954287, 0.388668, 0.759049, -0.501683, -1.98722, 0.158712, -0.897082, -1.17644, 0.192465, -1.49901, -0.289129, -0.0460198, -0.520331, 0.432488, -0.471775, 1.21482, 0.998091, -0.794933, -0.36989, 0.937091, 1.27297, 1.06108, -0.784307, 0.70919, -0.309221, -0.516031, 0.479702, -0.669637, 1.60288, 0.657474, -0.666286, -1.01816, -0.452818, -0.283749, 1.05511, -1.2002, 0.112269, -1.37403, 1.00512, 0.664936, 0.600516, -1.08099, -0.705522, 0.103051, 0.0461179, 1.74404, 0.727475, 2.41175, 1.20414, 1.71095, 0.0957544, 0.610755, 0.545194, -0.936381, 0.190467, 0.485791, 0.0855697, 0.142676, 0.721754, -1.84506, 2.1227, -1.1271, -1.11228, -1.2807, 0.13385, 0.228727, -0.34391, 1.09837, -0.37053, 0.832574, 0.673463, 0.717732, -0.307687, 1.12486, 0.159803, -1.51251, 1.403, 2.0215, 0.010914, -0.543749, 0.137119, 0.200364, -0.104029, -0.930966, -1.56781, -0.526978, -0.537582, 1.11872, -0.99061, -0.501421, 1.21982, 0.813201, -0.539109, 0.433523, -0.0615188, 2.04298, 0.697692, 1.34515, 1.7298, 0.515137, 2.08119, 0.550985, 1.49876, 1.31187, 0.920405, 0.597678, 0.884353, -0.732892, -0.143545, -0.236836, -0.330872, 1.55577, -1.74473, -0.493322, 1.46375, 1.14347, 1.76164, 1.73099, -0.234701, -0.0546848, 0.346991, -0.393301, 1.34267, -1.58519, -0.381789, 0.622675, 1.34655, 2.84895, -0.371, -0.519666, -1.64944, 0.573592, 1.06484, -0.0239894, -0.604563, 0.0680641, -0.881325, 1.07265, 0.182585, 0.373288, 2.20228, -0.763593, -0.25659, 1.9397, -0.166943, -0.672522, -1.35983, 0.227406, 0.49471, -1.23535, -0.479552, 1.97798, 0.418181, 1.23454, -0.0767748, 0.828642, -0.0348468, -0.264499, 0.76699, -0.910363, -2.11408, -0.209169, 0.902191, -2.27096, 0.098513, -0.380699, -0.231276, -0.0296834, 0.834972, -0.658283, 0.616493, 0.198916, -1.89783, -1.30219, 0.51036, 0.195825, -1.68961, -1.27838, 0.879616, 0.566719, 1.21876, 0.270402, -1.38261, 0.365878, 1.54191, 1.25104, 1.23067, 1.87261);y <- c(0.986442, 2.65684, -1.79726, 1.79999, -2.43971, -1.68358, -1.84081, -2.27973, 2.96046, 2.61837, 1.48756, 1.63497, 1.46876, 2.09348, -0.925101, 3.6792, -2.03618, 1.33232, -0.0652269, 0.809911, -2.82019, -1.87691, 1.1284, 0.249619, -2.94777, 3.00423, -2.79901, -0.110801, -3.546, 1.67156, -3.10723, -3.24205, 3.16911, -3.24227, -1.29801, 0.271933, -2.83573, -0.79973, -2.34429, -0.905163, -0.197905, -3.05664, -0.694481, 1.89301, -2.70264, 2.94361, -2.32469, 1.9576, 1.73556, -3.29777, -1.54311, -2.03172, -0.871756, 0.77581, 3.7692, 1.54446, 3.92129, 0.160296, -3.45486, -1.56317, -2.72913, 0.695854, 3.15786, 1.1006, 3.25649, -1.57206, -3.15353, 0.242301, -1.95855, -0.256919, 3.04782, -0.505045, -2.35542, 2.11649, -1.73363, 2.65149, 3.66302, 0.457907, -2.2759, -2.36105, -2.49263, -2.9784, -3.53525, -0.699404, 3.17647, -1.52424, 2.72699, 3.82774, 0.100029, 3.42107, 1.74672, 3.1279, -0.793162, -0.025109, 1.07262, 2.4517, -2.00605, -3.6625, -2.57031, -2.43599, 2.56309, -1.31707, -2.10777, -3.75394, 0.954311, 0.496025, 3.82545, -3.74259, -1.96145, 0.366455, 3.97474, 3.26111, -3.69904, 2.07392, 0.591191, -3.34162, -0.926126, 1.03966, -2.68754, -2.69653, 0.651845, 2.82333, 2.25596, 3.26545, -2.57379, 2.69137, -3.08119, 2.99114, -3.86005, -1.30995, 1.80096, 1.39404, -2.6482, -2.12922, -3.28834, -1.06563, -1.6683, -2.023, 1.60516, -1.67431, 1.38595, 0.287423, 2.56888, -2.99169, 0.549401, 2.31817, -2.48251, 2.20152, 1.0531, -3.60478, 0.327999, 0.475523, -0.454324, -2.63147, -1.61249, -1.65507, 1.13203, 0.218, 2.87289, -0.279036, -0.316795, 3.22757, -2.25, -1.10923, 0.0949814, -2.60818, -0.181803, 3.65484, 2.86193, 0.940815, 3.5461, 1.23983, 2.01177, -0.428626, 3.5539, -2.63454, 1.63098, 3.69696, 0.404995, 0.480342, 3.22724, -3.57127, -2.38176, -1.23267, 0.738668, 1.64966, 1.37331, -2.60132, -1.60081, 2.57359, -3.58266, 1.32347, 3.24265, 3.81, 3.90706, -0.407994, 2.42083, 3.34477, 3.43151, -1.08974, -2.93732, 2.39014, -1.36511, -0.101514, -1.46445, 2.11849, -3.63955, -1.57038, 3.41777, -1.00185, -0.0702487, 2.01317, -3.38133, 3.64754, -0.740182, -3.64028, -3.77238, 2.45613, -3.11631, 3.82543, 2.15285, -0.790691, -1.22153, -0.943069, -3.37327, 1.19097, 1.48834, 0.502127, -2.90383, -3.4236, -0.676889, 3.41785, 2.54728, -2.60006, -3.25969, -1.85346, -2.8088, 3.3905, -1.34015, -1.3877, 2.38485, 3.16688, -3.26326, -1.94801, 0.0878641, 0.492529, 2.62313, -2.08994, -1.77721, 1.92357, 0.739532, 0.869021, -3.82981, 3.92422, -1.16293, 3.82139, -1.67119, 1.1145, -2.24382, -1.93777, -0.109559, -0.350947, 1.94832, -2.54192, 1.224, 0.797731, 0.767982, -2.93565, -2.72896, 1.2624, 1.91513, -3.96412, 3.43534, 0.358804, 3.05541, -0.213663, 0.38204, -0.539063, -0.897154, -2.91298, -0.198784, -0.0732228, 2.99983, 3.54078, 2.27245, 3.87904, 2.99445, -0.705307, 0.187173, 1.79102, 1.69581, 2.08613, 1.54021, 0.7471, -1.19008, 2.44732, -1.59312, 1.5387, -0.526756, 3.06958, -1.707, -2.46148, -0.523427, -0.675584, -3.02611, -2.22116, -3.4546, -2.94353, 2.1346, 3.51197, 1.85137, 1.7461, -0.875901, -2.13891, -2.1714, 1.6953, -0.159958, 1.77583, -0.808156, 2.04446, 3.58507, -1.27303, -0.0739294, 0.22885, -1.16883, -0.0437807, -1.30141, 2.71702, 2.85379, 3.74969, 3.5839, -0.159889, -0.236555, 2.78411, 2.15217, -0.945737, -1.90692, 0.536403, -1.08419, -3.75986, 2.65243, -2.29661, 3.8776, 1.23146, -2.26545, 2.79205, 2.34152, -3.62388, -3.51983, -0.152083, -0.77672, -0.0661756, -1.12531, 1.77691, -1.49266, -0.401453, -2.98782, 1.15182, 3.00211, -0.338523, 2.63385, -1.30166, -1.96304, -2.03665, -2.91373, 3.33512, 0.26508, -2.4008, -0.989122, -1.96516, 0.498154, -0.139963, 1.762, -0.36494, 2.42886, 1.26076, -0.344707, -2.2629, 3.01517, -0.192693, 1.72579, -3.09541, 0.898774, -3.33187, -2.09473, 2.13997, -1.20736, -1.78102, 0.661333, -2.15738, -2.82721, -0.34423, 0.945198, -1.3919, 2.24165, -1.72333, -3.61333, 0.177856, -0.499845, 1.08322, -0.57797, 1.32396, -0.580476, -0.990233, 3.13608, 0.2254, 2.44513, -1.43021, -2.20293, -0.0295935, 3.9359, 0.872028, 2.94495, 2.3334, -1.4539, -2.0155, 1.90474, -1.83284, -3.6983, -0.223583, -2.19197, 2.98892, 2.11877, -0.614374, 0.860207, 3.63726, -1.54793, 0.699044, -3.31199, -2.87789, 3.21311, -3.24507, -0.0689166, 0.225146, -2.84127, -3.67944, 0.763724, -3.93721, -3.81518, -1.06853, 0.726999, 0.562243, 3.79879, 3.75762, 2.1455, 2.00329, -0.400098, -1.80113, 3.49374, 3.26726, -1.24347, 2.0535, 2.55697, 0.670452, -2.79004, 1.39668, 2.32366, -2.27311, -0.352436, -2.71256, -2.31389, -2.11829, 0.111656, -1.67798, 2.97944, -3.7505, -1.88802, 3.50199, 1.31453, 3.32241, -1.04754, -3.03124, 1.60895, 1.15746, 2.29443, 3.31704, -0.172815, 2.81695, 0.253896, 0.298466, -3.90939, -2.39831, 3.46711, 2.41166, 2.03439, 0.387814, -3.40236, -3.71227, -1.68499, -3.81028, 2.97335, 3.32693, -3.88281, -2.61789, -3.31616, 2.71789, 3.05144, -0.579528, -0.672907, 2.75653);quartz(width=4, height=4, type="pdf", file="~/Desktop/testpdf.pdf");plot(x=x, y=y, xlim=c(-5, 5), ylim=c(-5, 5), pch=19, cex=0.5, main="2000");dev.off();}’

  If I execute the R code that is in the -e argument directly in R GUI (on OS X) it works fine.  And if I put that code in a file and run Rscript <file>, it works fine.  So the length limit is not intrinsic to R’s parser, it would seem.  But if I try to execute exactly the same code in an interactive R session in my Unix terminal's command line, I get a continuation prompt, +, and a little investigation indicates that the input line may have been truncated after 3843 characters (a strange number) and it is waiting for more input to follow that truncated input.  And – what is most relevant for my situation – if I try to run the full Rscript command as given above (inside /bin/sh), it prints out:

WARNING: '-e {x~+~<-~+~c(-1.31171,~+~-0.686165,~+~1.62771,~+~0.320195,~+~-0.322011,~+~1.66518,~+~-0.271971,~+~-0.665367,~+~0.516482,~+~-0.716343,~+~-0.317471,~+~0.068046,~+~-0.100371,~+~-1.15907,~+~0.263329,~+~-0.936049,~+~-0.852444,~+~0.358817,~+~-0.233959,~+~0.209891,~+~-0.831575,~+~-0.952987,~+~-0.0420206,~+~-1.78527,~+~-0.280584,~+~-0.62353,~+~1.42597,~+~0.127994,~+~0.0751232,~+~0.896835,~+~-0.319488,~+~0.897876,~+~0.18457,~+~0.779571,~+~-0.0543194,~+~0.226722,~+~-0.769983,~+~-0.723463,~+~0.144386,~+~-0.468544,~+~-0.349417,~+~0.336786,~+~0.749212,~+~-1.62397,~+~0.683075,~+~-0.746449,~+~0.300921,~+~-0.365468,~+~0.548271,~+~1.13169,~+~-1.34042,~+~-0.0740572,~+~1.34986,~+~0.531771,~+~-0.147157,~+~0.824894,~+~-1.05816,~+~1.58867,~+~-0.885764,~+~1.11912,~+~0.361512,~+~1.77985,~+~0.585099,~+~-1.205,~+~2.44134,~+~-0.331372,~+~-0.346322,~+~0.0535267,~+~-1.75089,~+~0.0773243,~+~-1.07846,~+~-1.29632,~+~1.0622,~+~1.34867,~+~0.199777,~+~0.197516,~+~0.574185,~+~1.06555,~+~-0.885166,~+~-0.788576,~+~-1.46061,~+~-1.5402

and then it hangs – the full warning doesn’t complete printing, so it is not clear what it is trying to warn about.  That represents 844 characters of input script, but with the weird way that spaces have been replaced by ~+~ by somebody, it is 1013 characters – suspiciously close to 1024.

  Note that if I simply make the R script shorter, by plotting 100 x/y values instead of 500, everything works fine.  So there is no issue with the way that I’m quoting strings or anything like that; the only issue seems to be the total length of the command line.

  Now of course I could break up the script into multiple chunks, passed via separate -e arguments, and perhaps that would work somewhat better.  But given that I want to set up a vector x with a single c() command containing all of the data for x, I will still hit a line length limit; the single line of code to set up x will already be over the maximum line length that Rscript allows for a -e argument, apparently.  Getting around that would obviously be possible too, but would be considerably more hassle.

  And incidentally, this seems to have nothing to do with the /bin/sh input line limit; that is much higher.  According to "getconf ARG_MAX”, it is 262144 characters on my machine, which is more than enough headroom for what I’m trying to do.

  So my questions are: (1) is this a bug, (2) if so, do you think you are likely to fix it any time soon :->, and (3) if the answer to that is no, are there any standard workarounds for this sort of situation that you would recommend?  I suppose I could write out the script to a file and then execute that file with Rscript, since that seems to work; but I was really hoping to avoid that extra complication and overhead.  Is there a better way?

  Thanks for any help you can provide!  :->

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Maximum length for a -e argument to Rscript?

Ben Tupper-2
Hi,

I suspect you are over the 10kb limit for the expression.  See

https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Invoking-R-from-the-command-line

Cheers,
Ben

> On Apr 21, 2017, at 3:44 AM, Ben Haller <[hidden email]> wrote:
>
>  Hi!  I’m attempting to use Rscript to do some automated plotting.  It is working well, except that I seem to be running into a maximum line length issue, and I’m wondering if it is a bug on your end.  Here’s an example of the command I’m trying to run:
>
> /usr/local/bin/Rscript -e '{x <- c(-1.31171, -0.686165, 1.62771, 0.320195, -0.322011, 1.66518, -0.271971, -0.665367, 0.516482, -0.716343, -0.317471, 0.068046, -0.100371, -1.15907, 0.263329, -0.936049, -0.852444, 0.358817, -0.233959, 0.209891, -0.831575, -0.952987, -0.0420206, -1.78527, -0.280584, -0.62353, 1.42597, 0.127994, 0.0751232, 0.896835, -0.319488, 0.897876, 0.18457, 0.779571, -0.0543194, 0.226722, -0.769983, -0.723463, 0.144386, -0.468544, -0.349417, 0.336786, 0.749212, -1.62397, 0.683075, -0.746449, 0.300921, -0.365468, 0.548271, 1.13169, -1.34042, -0.0740572, 1.34986, 0.531771, -0.147157, 0.824894, -1.05816, 1.58867, -0.885764, 1.11912, 0.361512, 1.77985, 0.585099, -1.205, 2.44134, -0.331372, -0.346322, 0.0535267, -1.75089, 0.0773243, -1.07846, -1.29632, 1.0622, 1.34867, 0.199777, 0.197516, 0.574185, 1.06555, -0.885166, -0.788576, -1.46061, -1.54026, 0.690576, -0.88821, 0.343747, -0.100751, -0.865596, -0.128504, 0.222334, -1.18932, -0.555258, -0.557368, 0.219272, 0.298858, 0.848022, 0.142608, 1.10082, -0.348039, 0.0566489, 0.662136, 0.50451, -0.909399, 1.02446, 1.40592, -0.114786, -1.10718, 2.02549, 0.0818607, -1.037, 1.18961, -0.204, 2.83165, -0.959653, -0.393082, -0.463351, 0.914054, 1.14472, -1.32927, 1.25416, 0.372267, 0.410832, 1.04187, 1.22288, 1.27131, 0.0949385, 0.194053, -0.226184, -0.502155, -1.36834, -0.000591861, -0.565903, 1.14099, 1.67811, 0.331709, -0.756879, 0.889596, 0.718098, 0.740242, -0.861818, 0.0332746, 1.01745, 0.584536, -1.14245, -0.444485, -1.34237, 0.660603, 1.16048, -0.898828, 0.965746, -1.16953, -2.33417, 0.591078, -0.364892, 0.0719267, -1.21676, 1.12646, 1.37534, 0.0712832, 1.22889, -0.0110024, 0.248213, -1.12013, -0.525197, -0.352156, -0.317182, -0.89552, 1.53422, -1.36777, 1.52099, 1.18789, -3.15251, 1.24008, -0.564289, -0.515629, -0.0920464, 2.94027, 0.895481, -0.157643, -0.347874, -0.290823, -0.771436, 1.29285, 0.216689, -1.86856, 2.24075, 0.888635, 0.430417, -0.585856, 1.13119, -0.243977, 0.544491, 0.921995, 0.815365, 1.2584, -1.29347, 0.0574579, 0.990557, -1.58657, -0.264373, 0.865893, 0.599298, -0.417531, 0.132897, 1.88597, 1.33112, -0.880904, 0.0762161, 0.0567852, 0.593295, -0.632135, 0.885625, 0.365863, -0.17885, 0.420185, -0.508275, 0.974357, 0.628085, 0.710578, 1.72447, 1.38488, 1.01301, 1.30015, 0.260501, 0.808981, 0.440228, 0.416344, -1.66273, -0.397224, -0.512086, -0.175854, -0.663143, 0.369712, -1.01654, 0.660465, 0.124851, -1.51101, -0.95725, 2.09893, 1.26819, 1.08086, 0.493204, 0.79073, 1.49191, 0.563689, 0.414473, 2.27361, 0.871923, 0.193703, -0.185039, -0.312859, -1.42267, -2.11561, 0.311996, -0.0906527, 1.19139, 1.57502, 1.10587, 0.416333, 2.35374, -1.0531, 0.0450512, 0.979958, 0.398269, 0.0897618, -0.855305, -1.59337, -0.084904, 0.245872, 1.27115, 1.3512, -0.166962, 1.01098, -1.19854, -2.05932, -0.98, 0.704973, 0.694688, 1.20408, -1.12553, 0.770056, 1.01602, 0.295223, -1.18801, 1.51707, 1.1418, -0.148787, 1.28886, 1.23981, 1.67984, 0.0185941, -0.877581, 0.495042, -0.368668, 1.59972, -2.20849, -1.36852, -0.972566, -1.01848, -0.366674, -2.60273, -0.540706, -0.475797, 0.227651, -1.11476, 1.73452, -0.212185, 3.04994, -0.251225, -0.0443482, -0.489125, 0.557936, -0.246389, -0.954287, 0.388668, 0.759049, -0.501683, -1.98722, 0.158712, -0.897082, -1.17644, 0.192465, -1.49901, -0.289129, -0.0460198, -0.520331, 0.432488, -0.471775, 1.21482, 0.998091, -0.794933, -0.36989, 0.937091, 1.27297, 1.06108, -0.784307, 0.70919, -0.309221, -0.516031, 0.479702, -0.669637, 1.60288, 0.657474, -0.666286, -1.01816, -0.452818, -0.283749, 1.05511, -1.2002, 0.112269, -1.37403, 1.00512, 0.664936, 0.600516, -1.08099, -0.705522, 0.103051, 0.0461179, 1.74404, 0.727475, 2.41175, 1.20414, 1.71095, 0.0957544, 0.610755, 0.545194, -0.936381, 0.190467, 0.485791, 0.0855697, 0.142676, 0.721754, -1.84506, 2.1227, -1.1271, -1.11228, -1.2807, 0.13385, 0.228727, -0.34391, 1.09837, -0.37053, 0.832574, 0.673463, 0.717732, -0.307687, 1.12486, 0.159803, -1.51251, 1.403, 2.0215, 0.010914, -0.543749, 0.137119, 0.200364, -0.104029, -0.930966, -1.56781, -0.526978, -0.537582, 1.11872, -0.99061, -0.501421, 1.21982, 0.813201, -0.539109, 0.433523, -0.0615188, 2.04298, 0.697692, 1.34515, 1.7298, 0.515137, 2.08119, 0.550985, 1.49876, 1.31187, 0.920405, 0.597678, 0.884353, -0.732892, -0.143545, -0.236836, -0.330872, 1.55577, -1.74473, -0.493322, 1.46375, 1.14347, 1.76164, 1.73099, -0.234701, -0.0546848, 0.346991, -0.393301, 1.34267, -1.58519, -0.381789, 0.622675, 1.34655, 2.84895, -0.371, -0.519666, -1.64944, 0.573592, 1.06484, -0.0239894, -0.604563, 0.0680641, -0.881325, 1.07265, 0.182585, 0.373288, 2.20228, -0.763593, -0.25659, 1.9397, -0.166943, -0.672522, -1.35983, 0.227406, 0.49471, -1.23535, -0.479552, 1.97798, 0.418181, 1.23454, -0.0767748, 0.828642, -0.0348468, -0.264499, 0.76699, -0.910363, -2.11408, -0.209169, 0.902191, -2.27096, 0.098513, -0.380699, -0.231276, -0.0296834, 0.834972, -0.658283, 0.616493, 0.198916, -1.89783, -1.30219, 0.51036, 0.195825, -1.68961, -1.27838, 0.879616, 0.566719, 1.21876, 0.270402, -1.38261, 0.365878, 1.54191, 1.25104, 1.23067, 1.87261);y <- c(0.986442, 2.65684, -1.79726, 1.79999, -2.43971, -1.68358, -1.84081, -2.27973, 2.96046, 2.61837, 1.48756, 1.63497, 1.46876, 2.09348, -0.925101, 3.6792, -2.03618, 1.33232, -0.0652269, 0.809911, -2.82019, -1.87691, 1.1284, 0.249619, -2.94777, 3.00423, -2.79901, -0.110801, -3.546, 1.67156, -3.10723, -3.24205, 3.16911, -3.24227, -1.29801, 0.271933, -2.83573, -0.79973, -2.34429, -0.905163, -0.197905, -3.05664, -0.694481, 1.89301, -2.70264, 2.94361, -2.32469, 1.9576, 1.73556, -3.29777, -1.54311, -2.03172, -0.871756, 0.77581, 3.7692, 1.54446, 3.92129, 0.160296, -3.45486, -1.56317, -2.72913, 0.695854, 3.15786, 1.1006, 3.25649, -1.57206, -3.15353, 0.242301, -1.95855, -0.256919, 3.04782, -0.505045, -2.35542, 2.11649, -1.73363, 2.65149, 3.66302, 0.457907, -2.2759, -2.36105, -2.49263, -2.9784, -3.53525, -0.699404, 3.17647, -1.52424, 2.72699, 3.82774, 0.100029, 3.42107, 1.74672, 3.1279, -0.793162, -0.025109, 1.07262, 2.4517, -2.00605, -3.6625, -2.57031, -2.43599, 2.56309, -1.31707, -2.10777, -3.75394, 0.954311, 0.496025, 3.82545, -3.74259, -1.96145, 0.366455, 3.97474, 3.26111, -3.69904, 2.07392, 0.591191, -3.34162, -0.926126, 1.03966, -2.68754, -2.69653, 0.651845, 2.82333, 2.25596, 3.26545, -2.57379, 2.69137, -3.08119, 2.99114, -3.86005, -1.30995, 1.80096, 1.39404, -2.6482, -2.12922, -3.28834, -1.06563, -1.6683, -2.023, 1.60516, -1.67431, 1.38595, 0.287423, 2.56888, -2.99169, 0.549401, 2.31817, -2.48251, 2.20152, 1.0531, -3.60478, 0.327999, 0.475523, -0.454324, -2.63147, -1.61249, -1.65507, 1.13203, 0.218, 2.87289, -0.279036, -0.316795, 3.22757, -2.25, -1.10923, 0.0949814, -2.60818, -0.181803, 3.65484, 2.86193, 0.940815, 3.5461, 1.23983, 2.01177, -0.428626, 3.5539, -2.63454, 1.63098, 3.69696, 0.404995, 0.480342, 3.22724, -3.57127, -2.38176, -1.23267, 0.738668, 1.64966, 1.37331, -2.60132, -1.60081, 2.57359, -3.58266, 1.32347, 3.24265, 3.81, 3.90706, -0.407994, 2.42083, 3.34477, 3.43151, -1.08974, -2.93732, 2.39014, -1.36511, -0.101514, -1.46445, 2.11849, -3.63955, -1.57038, 3.41777, -1.00185, -0.0702487, 2.01317, -3.38133, 3.64754, -0.740182, -3.64028, -3.77238, 2.45613, -3.11631, 3.82543, 2.15285, -0.790691, -1.22153, -0.943069, -3.37327, 1.19097, 1.48834, 0.502127, -2.90383, -3.4236, -0.676889, 3.41785, 2.54728, -2.60006, -3.25969, -1.85346, -2.8088, 3.3905, -1.34015, -1.3877, 2.38485, 3.16688, -3.26326, -1.94801, 0.0878641, 0.492529, 2.62313, -2.08994, -1.77721, 1.92357, 0.739532, 0.869021, -3.82981, 3.92422, -1.16293, 3.82139, -1.67119, 1.1145, -2.24382, -1.93777, -0.109559, -0.350947, 1.94832, -2.54192, 1.224, 0.797731, 0.767982, -2.93565, -2.72896, 1.2624, 1.91513, -3.96412, 3.43534, 0.358804, 3.05541, -0.213663, 0.38204, -0.539063, -0.897154, -2.91298, -0.198784, -0.0732228, 2.99983, 3.54078, 2.27245, 3.87904, 2.99445, -0.705307, 0.187173, 1.79102, 1.69581, 2.08613, 1.54021, 0.7471, -1.19008, 2.44732, -1.59312, 1.5387, -0.526756, 3.06958, -1.707, -2.46148, -0.523427, -0.675584, -3.02611, -2.22116, -3.4546, -2.94353, 2.1346, 3.51197, 1.85137, 1.7461, -0.875901, -2.13891, -2.1714, 1.6953, -0.159958, 1.77583, -0.808156, 2.04446, 3.58507, -1.27303, -0.0739294, 0.22885, -1.16883, -0.0437807, -1.30141, 2.71702, 2.85379, 3.74969, 3.5839, -0.159889, -0.236555, 2.78411, 2.15217, -0.945737, -1.90692, 0.536403, -1.08419, -3.75986, 2.65243, -2.29661, 3.8776, 1.23146, -2.26545, 2.79205, 2.34152, -3.62388, -3.51983, -0.152083, -0.77672, -0.0661756, -1.12531, 1.77691, -1.49266, -0.401453, -2.98782, 1.15182, 3.00211, -0.338523, 2.63385, -1.30166, -1.96304, -2.03665, -2.91373, 3.33512, 0.26508, -2.4008, -0.989122, -1.96516, 0.498154, -0.139963, 1.762, -0.36494, 2.42886, 1.26076, -0.344707, -2.2629, 3.01517, -0.192693, 1.72579, -3.09541, 0.898774, -3.33187, -2.09473, 2.13997, -1.20736, -1.78102, 0.661333, -2.15738, -2.82721, -0.34423, 0.945198, -1.3919, 2.24165, -1.72333, -3.61333, 0.177856, -0.499845, 1.08322, -0.57797, 1.32396, -0.580476, -0.990233, 3.13608, 0.2254, 2.44513, -1.43021, -2.20293, -0.0295935, 3.9359, 0.872028, 2.94495, 2.3334, -1.4539, -2.0155, 1.90474, -1.83284, -3.6983, -0.223583, -2.19197, 2.98892, 2.11877, -0.614374, 0.860207, 3.63726, -1.54793, 0.699044, -3.31199, -2.87789, 3.21311, -3.24507, -0.0689166, 0.225146, -2.84127, -3.67944, 0.763724, -3.93721, -3.81518, -1.06853, 0.726999, 0.562243, 3.79879, 3.75762, 2.1455, 2.00329, -0.400098, -1.80113, 3.49374, 3.26726, -1.24347, 2.0535, 2.55697, 0.670452, -2.79004, 1.39668, 2.32366, -2.27311, -0.352436, -2.71256, -2.31389, -2.11829, 0.111656, -1.67798, 2.97944, -3.7505, -1.88802, 3.50199, 1.31453, 3.32241, -1.04754, -3.03124, 1.60895, 1.15746, 2.29443, 3.31704, -0.172815, 2.81695, 0.253896, 0.298466, -3.90939, -2.39831, 3.46711, 2.41166, 2.03439, 0.387814, -3.40236, -3.71227, -1.68499, -3.81028, 2.97335, 3.32693, -3.88281, -2.61789, -3.31616, 2.71789, 3.05144, -0.579528, -0.672907, 2.75653);quartz(width=4, height=4, type="pdf", file="~/Desktop/testpdf.pdf");plot(x=x, y=y, xlim=c(-5, 5), ylim=c(-5, 5), pch=19, cex=0.5, main="2000");dev.off();}’
>
>  If I execute the R code that is in the -e argument directly in R GUI (on OS X) it works fine.  And if I put that code in a file and run Rscript <file>, it works fine.  So the length limit is not intrinsic to R’s parser, it would seem.  But if I try to execute exactly the same code in an interactive R session in my Unix terminal's command line, I get a continuation prompt, +, and a little investigation indicates that the input line may have been truncated after 3843 characters (a strange number) and it is waiting for more input to follow that truncated input.  And – what is most relevant for my situation – if I try to run the full Rscript command as given above (inside /bin/sh), it prints out:
>
> WARNING: '-e {x~+~<-~+~c(-1.31171,~+~-0.686165,~+~1.62771,~+~0.320195,~+~-0.322011,~+~1.66518,~+~-0.271971,~+~-0.665367,~+~0.516482,~+~-0.716343,~+~-0.317471,~+~0.068046,~+~-0.100371,~+~-1.15907,~+~0.263329,~+~-0.936049,~+~-0.852444,~+~0.358817,~+~-0.233959,~+~0.209891,~+~-0.831575,~+~-0.952987,~+~-0.0420206,~+~-1.78527,~+~-0.280584,~+~-0.62353,~+~1.42597,~+~0.127994,~+~0.0751232,~+~0.896835,~+~-0.319488,~+~0.897876,~+~0.18457,~+~0.779571,~+~-0.0543194,~+~0.226722,~+~-0.769983,~+~-0.723463,~+~0.144386,~+~-0.468544,~+~-0.349417,~+~0.336786,~+~0.749212,~+~-1.62397,~+~0.683075,~+~-0.746449,~+~0.300921,~+~-0.365468,~+~0.548271,~+~1.13169,~+~-1.34042,~+~-0.0740572,~+~1.34986,~+~0.531771,~+~-0.147157,~+~0.824894,~+~-1.05816,~+~1.58867,~+~-0.885764,~+~1.11912,~+~0.361512,~+~1.77985,~+~0.585099,~+~-1.205,~+~2.44134,~+~-0.331372,~+~-0.346322,~+~0.0535267,~+~-1.75089,~+~0.0773243,~+~-1.07846,~+~-1.29632,~+~1.0622,~+~1.34867,~+~0.199777,~+~0.197516,~+~0.574185,~+~1.06555,~+~-0.885166,~+~-0.788576,~+~-1.46061,~+~-1.5402
>
> and then it hangs – the full warning doesn’t complete printing, so it is not clear what it is trying to warn about.  That represents 844 characters of input script, but with the weird way that spaces have been replaced by ~+~ by somebody, it is 1013 characters – suspiciously close to 1024.
>
>  Note that if I simply make the R script shorter, by plotting 100 x/y values instead of 500, everything works fine.  So there is no issue with the way that I’m quoting strings or anything like that; the only issue seems to be the total length of the command line.
>
>  Now of course I could break up the script into multiple chunks, passed via separate -e arguments, and perhaps that would work somewhat better.  But given that I want to set up a vector x with a single c() command containing all of the data for x, I will still hit a line length limit; the single line of code to set up x will already be over the maximum line length that Rscript allows for a -e argument, apparently.  Getting around that would obviously be possible too, but would be considerably more hassle.
>
>  And incidentally, this seems to have nothing to do with the /bin/sh input line limit; that is much higher.  According to "getconf ARG_MAX”, it is 262144 characters on my machine, which is more than enough headroom for what I’m trying to do.
>
>  So my questions are: (1) is this a bug, (2) if so, do you think you are likely to fix it any time soon :->, and (3) if the answer to that is no, are there any standard workarounds for this sort of situation that you would recommend?  I suppose I could write out the script to a file and then execute that file with Rscript, since that seems to work; but I was really hoping to avoid that extra complication and overhead.  Is there a better way?
>
>  Thanks for any help you can provide!  :->
>
> Cheers,
> -B.
>
> Benjamin C. Haller
> Messer Lab
> Cornell University
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Maximum length for a -e argument to Rscript?

Henrik Bengtsson-5
That Rscript stalls sounds like a bug, but not sure it's R or the
terminal that needs to be fixed:

  Rscript -e "$long_expression"
WARNING: '-e {x~+~<-~+~c(-1.31171,~+~-0.686165,~+~1.62771,~+~0.320195,~+~-0.322011,~+~1.66518,~+~-0.271971,~+~-0.665367,~+~0.516482,~+~-0.716343,~+~-0.317471,~+~0.068046,~+~-0.100371,~+~-1.15907,~+~0.263329,~+~-0.936049,~+~-0.852444,~+~0.358817,~+~-0.233959,~+~0.209891,~+~-0.831575,~+~-0.952987,~+~-0.0420206,~+~-1.78527,~+~-0.280584,~+~-0.62353,~+~1.42597,~+~0.127994,~+~0.0751232,~+~0.896835,~+~-0.319488,~+~0.897876,~+~0.18457,~+~0.779571,~+~-0.0543194,~+~0.226722,~+~-0.769983,~+~-0.723463,~+~0.144386,~+~-0.468544,~+~-0.349417,~+~0.336786,~+~0.749212,~+~-1.62397,~+~0.683075,~+~-0.746449,~+~0.300921,~+~-0.365468,~+~0.548271,~+~1.13169,~+~-1.34042,~+~-0.0740572,~+~1.34986,~+~0.531771,~+~-0.147157,~+~0.824894,~+~-1.05816,~+~1.58867,~+~-0.885764,~+~1.11912,~+~0.361512,~+~1.77985,~+~0.585099,~+~-1.205,~+~2.44134,~+~-0.331372,~+~-0.346322,~+~0.0535267,~+~-1.75089,~+~0.0773243,~+~-1.07846,~+~-1.29632,~+~1.0622,~+~1.34867,~+~0.199777,~+~0.197516,~+~0.574185,~+~1.06555,~+~-0.885166,~+~-0.788576,~+~-1.46061,~+~-1.5402
^C^C
^C
^C^C^C^C^C^C
^\Quit (core dumped)

On my default Ubuntu 16.04 terminal, R 3.3.3 hangs and does not
respond to user interrupts (SIGINT), but it does respond to Ctrl-\
(SIGKILL).

A workaround is to pass the expression via standard input to R, e.g.

$ echo "$long_expression" | R --no-save

/Henrik

On Fri, Apr 21, 2017 at 11:07 AM, Ben Tupper <[hidden email]> wrote:

> Hi,
>
> I suspect you are over the 10kb limit for the expression.  See
>
> https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Invoking-R-from-the-command-line
>
> Cheers,
> Ben
>
>> On Apr 21, 2017, at 3:44 AM, Ben Haller <[hidden email]> wrote:
>>
>>  Hi!  I’m attempting to use Rscript to do some automated plotting.  It is working well, except that I seem to be running into a maximum line length issue, and I’m wondering if it is a bug on your end.  Here’s an example of the command I’m trying to run:
>>
>> /usr/local/bin/Rscript -e '{x <- c(-1.31171, -0.686165, 1.62771, 0.320195, -0.322011, 1.66518, -0.271971, -0.665367, 0.516482, -0.716343, -0.317471, 0.068046, -0.100371, -1.15907, 0.263329, -0.936049, -0.852444, 0.358817, -0.233959, 0.209891, -0.831575, -0.952987, -0.0420206, -1.78527, -0.280584, -0.62353, 1.42597, 0.127994, 0.0751232, 0.896835, -0.319488, 0.897876, 0.18457, 0.779571, -0.0543194, 0.226722, -0.769983, -0.723463, 0.144386, -0.468544, -0.349417, 0.336786, 0.749212, -1.62397, 0.683075, -0.746449, 0.300921, -0.365468, 0.548271, 1.13169, -1.34042, -0.0740572, 1.34986, 0.531771, -0.147157, 0.824894, -1.05816, 1.58867, -0.885764, 1.11912, 0.361512, 1.77985, 0.585099, -1.205, 2.44134, -0.331372, -0.346322, 0.0535267, -1.75089, 0.0773243, -1.07846, -1.29632, 1.0622, 1.34867, 0.199777, 0.197516, 0.574185, 1.06555, -0.885166, -0.788576, -1.46061, -1.54026, 0.690576, -0.88821, 0.343747, -0.100751, -0.865596, -0.128504, 0.222334, -1.18932, -0.555258, -0.557368, 0.219272, 0.298858, 0.848022, 0.142608, 1.10082, -0.348039, 0.0566489, 0.662136, 0.50451, -0.909399, 1.02446, 1.40592, -0.114786, -1.10718, 2.02549, 0.0818607, -1.037, 1.18961, -0.204, 2.83165, -0.959653, -0.393082, -0.463351, 0.914054, 1.14472, -1.32927, 1.25416, 0.372267, 0.410832, 1.04187, 1.22288, 1.27131, 0.0949385, 0.194053, -0.226184, -0.502155, -1.36834, -0.000591861, -0.565903, 1.14099, 1.67811, 0.331709, -0.756879, 0.889596, 0.718098, 0.740242, -0.861818, 0.0332746, 1.01745, 0.584536, -1.14245, -0.444485, -1.34237, 0.660603, 1.16048, -0.898828, 0.965746, -1.16953, -2.33417, 0.591078, -0.364892, 0.0719267, -1.21676, 1.12646, 1.37534, 0.0712832, 1.22889, -0.0110024, 0.248213, -1.12013, -0.525197, -0.352156, -0.317182, -0.89552, 1.53422, -1.36777, 1.52099, 1.18789, -3.15251, 1.24008, -0.564289, -0.515629, -0.0920464, 2.94027, 0.895481, -0.157643, -0.347874, -0.290823, -0.771436, 1.29285, 0.216689, -1.86856, 2.24075, 0.888635, 0.430417, -0.585856, 1.13119, -0.243977, 0.544491, 0.921995, 0.815365, 1.2584, -1.29347, 0.0574579, 0.990557, -1.58657, -0.264373, 0.865893, 0.599298, -0.417531, 0.132897, 1.88597, 1.33112, -0.880904, 0.0762161, 0.0567852, 0.593295, -0.632135, 0.885625, 0.365863, -0.17885, 0.420185, -0.508275, 0.974357, 0.628085, 0.710578, 1.72447, 1.38488, 1.01301, 1.30015, 0.260501, 0.808981, 0.440228, 0.416344, -1.66273, -0.397224, -0.512086, -0.175854, -0.663143, 0.369712, -1.01654, 0.660465, 0.124851, -1.51101, -0.95725, 2.09893, 1.26819, 1.08086, 0.493204, 0.79073, 1.49191, 0.563689, 0.414473, 2.27361, 0.871923, 0.193703, -0.185039, -0.312859, -1.42267, -2.11561, 0.311996, -0.0906527, 1.19139, 1.57502, 1.10587, 0.416333, 2.35374, -1.0531, 0.0450512, 0.979958, 0.398269, 0.0897618, -0.855305, -1.59337, -0.084904, 0.245872, 1.27115, 1.3512, -0.166962, 1.01098, -1.19854, -2.05932, -0.98, 0.704973, 0.694688, 1.20408, -1.12553, 0.770056, 1.01602, 0.295223, -1.18801, 1.51707, 1.1418, -0.148787, 1.28886, 1.23981, 1.67984, 0.0185941, -0.877581, 0.495042, -0.368668, 1.59972, -2.20849, -1.36852, -0.972566, -1.01848, -0.366674, -2.60273, -0.540706, -0.475797, 0.227651, -1.11476, 1.73452, -0.212185, 3.04994, -0.251225, -0.0443482, -0.489125, 0.557936, -0.246389, -0.954287, 0.388668, 0.759049, -0.501683, -1.98722, 0.158712, -0.897082, -1.17644, 0.192465, -1.49901, -0.289129, -0.0460198, -0.520331, 0.432488, -0.471775, 1.21482, 0.998091, -0.794933, -0.36989, 0.937091, 1.27297, 1.06108, -0.784307, 0.70919, -0.309221, -0.516031, 0.479702, -0.669637, 1.60288, 0.657474, -0.666286, -1.01816, -0.452818, -0.283749, 1.05511, -1.2002, 0.112269, -1.37403, 1.00512, 0.664936, 0.600516, -1.08099, -0.705522, 0.103051, 0.0461179, 1.74404, 0.727475, 2.41175, 1.20414, 1.71095, 0.0957544, 0.610755, 0.545194, -0.936381, 0.190467, 0.485791, 0.0855697, 0.142676, 0.721754, -1.84506, 2.1227, -1.1271, -1.11228, -1.2807, 0.13385, 0.228727, -0.34391, 1.09837, -0.37053, 0.832574, 0.673463, 0.717732, -0.307687, 1.12486, 0.159803, -1.51251, 1.403, 2.0215, 0.010914, -0.543749, 0.137119, 0.200364, -0.104029, -0.930966, -1.56781, -0.526978, -0.537582, 1.11872, -0.99061, -0.501421, 1.21982, 0.813201, -0.539109, 0.433523, -0.0615188, 2.04298, 0.697692, 1.34515, 1.7298, 0.515137, 2.08119, 0.550985, 1.49876, 1.31187, 0.920405, 0.597678, 0.884353, -0.732892, -0.143545, -0.236836, -0.330872, 1.55577, -1.74473, -0.493322, 1.46375, 1.14347, 1.76164, 1.73099, -0.234701, -0.0546848, 0.346991, -0.393301, 1.34267, -1.58519, -0.381789, 0.622675, 1.34655, 2.84895, -0.371, -0.519666, -1.64944, 0.573592, 1.06484, -0.0239894, -0.604563, 0.0680641, -0.881325, 1.07265, 0.182585, 0.373288, 2.20228, -0.763593, -0.25659, 1.9397, -0.166943, -0.672522, -1.35983, 0.227406, 0.49471, -1.23535, -0.479552, 1.97798, 0.418181, 1.23454, -0.0767748, 0.828642, -0.0348468, -0.264499, 0.76699, -0.910363, -2.11408, -0.209169, 0.902191, -2.27096, 0.098513, -0.380699, -0.231276, -0.0296834, 0.834972, -0.658283, 0.616493, 0.198916, -1.89783, -1.30219, 0.51036, 0.195825, -1.68961, -1.27838, 0.879616, 0.566719, 1.21876, 0.270402, -1.38261, 0.365878, 1.54191, 1.25104, 1.23067, 1.87261);y <- c(0.986442, 2.65684, -1.79726, 1.79999, -2.43971, -1.68358, -1.84081, -2.27973, 2.96046, 2.61837, 1.48756, 1.63497, 1.46876, 2.09348, -0.925101, 3.6792, -2.03618, 1.33232, -0.0652269, 0.809911, -2.82019, -1.87691, 1.1284, 0.249619, -2.94777, 3.00423, -2.79901, -0.110801, -3.546, 1.67156, -3.10723, -3.24205, 3.16911, -3.24227, -1.29801, 0.271933, -2.83573, -0.79973, -2.34429, -0.905163, -0.197905, -3.05664, -0.694481, 1.89301, -2.70264, 2.94361, -2.32469, 1.9576, 1.73556, -3.29777, -1.54311, -2.03172, -0.871756, 0.77581, 3.7692, 1.54446, 3.92129, 0.160296, -3.45486, -1.56317, -2.72913, 0.695854, 3.15786, 1.1006, 3.25649, -1.57206, -3.15353, 0.242301, -1.95855, -0.256919, 3.04782, -0.505045, -2.35542, 2.11649, -1.73363, 2.65149, 3.66302, 0.457907, -2.2759, -2.36105, -2.49263, -2.9784, -3.53525, -0.699404, 3.17647, -1.52424, 2.72699, 3.82774, 0.100029, 3.42107, 1.74672, 3.1279, -0.793162, -0.025109, 1.07262, 2.4517, -2.00605, -3.6625, -2.57031, -2.43599, 2.56309, -1.31707, -2.10777, -3.75394, 0.954311, 0.496025, 3.82545, -3.74259, -1.96145, 0.366455, 3.97474, 3.26111, -3.69904, 2.07392, 0.591191, -3.34162, -0.926126, 1.03966, -2.68754, -2.69653, 0.651845, 2.82333, 2.25596, 3.26545, -2.57379, 2.69137, -3.08119, 2.99114, -3.86005, -1.30995, 1.80096, 1.39404, -2.6482, -2.12922, -3.28834, -1.06563, -1.6683, -2.023, 1.60516, -1.67431, 1.38595, 0.287423, 2.56888, -2.99169, 0.549401, 2.31817, -2.48251, 2.20152, 1.0531, -3.60478, 0.327999, 0.475523, -0.454324, -2.63147, -1.61249, -1.65507, 1.13203, 0.218, 2.87289, -0.279036, -0.316795, 3.22757, -2.25, -1.10923, 0.0949814, -2.60818, -0.181803, 3.65484, 2.86193, 0.940815, 3.5461, 1.23983, 2.01177, -0.428626, 3.5539, -2.63454, 1.63098, 3.69696, 0.404995, 0.480342, 3.22724, -3.57127, -2.38176, -1.23267, 0.738668, 1.64966, 1.37331, -2.60132, -1.60081, 2.57359, -3.58266, 1.32347, 3.24265, 3.81, 3.90706, -0.407994, 2.42083, 3.34477, 3.43151, -1.08974, -2.93732, 2.39014, -1.36511, -0.101514, -1.46445, 2.11849, -3.63955, -1.57038, 3.41777, -1.00185, -0.0702487, 2.01317, -3.38133, 3.64754, -0.740182, -3.64028, -3.77238, 2.45613, -3.11631, 3.82543, 2.15285, -0.790691, -1.22153, -0.943069, -3.37327, 1.19097, 1.48834, 0.502127, -2.90383, -3.4236, -0.676889, 3.41785, 2.54728, -2.60006, -3.25969, -1.85346, -2.8088, 3.3905, -1.34015, -1.3877, 2.38485, 3.16688, -3.26326, -1.94801, 0.0878641, 0.492529, 2.62313, -2.08994, -1.77721, 1.92357, 0.739532, 0.869021, -3.82981, 3.92422, -1.16293, 3.82139, -1.67119, 1.1145, -2.24382, -1.93777, -0.109559, -0.350947, 1.94832, -2.54192, 1.224, 0.797731, 0.767982, -2.93565, -2.72896, 1.2624, 1.91513, -3.96412, 3.43534, 0.358804, 3.05541, -0.213663, 0.38204, -0.539063, -0.897154, -2.91298, -0.198784, -0.0732228, 2.99983, 3.54078, 2.27245, 3.87904, 2.99445, -0.705307, 0.187173, 1.79102, 1.69581, 2.08613, 1.54021, 0.7471, -1.19008, 2.44732, -1.59312, 1.5387, -0.526756, 3.06958, -1.707, -2.46148, -0.523427, -0.675584, -3.02611, -2.22116, -3.4546, -2.94353, 2.1346, 3.51197, 1.85137, 1.7461, -0.875901, -2.13891, -2.1714, 1.6953, -0.159958, 1.77583, -0.808156, 2.04446, 3.58507, -1.27303, -0.0739294, 0.22885, -1.16883, -0.0437807, -1.30141, 2.71702, 2.85379, 3.74969, 3.5839, -0.159889, -0.236555, 2.78411, 2.15217, -0.945737, -1.90692, 0.536403, -1.08419, -3.75986, 2.65243, -2.29661, 3.8776, 1.23146, -2.26545, 2.79205, 2.34152, -3.62388, -3.51983, -0.152083, -0.77672, -0.0661756, -1.12531, 1.77691, -1.49266, -0.401453, -2.98782, 1.15182, 3.00211, -0.338523, 2.63385, -1.30166, -1.96304, -2.03665, -2.91373, 3.33512, 0.26508, -2.4008, -0.989122, -1.96516, 0.498154, -0.139963, 1.762, -0.36494, 2.42886, 1.26076, -0.344707, -2.2629, 3.01517, -0.192693, 1.72579, -3.09541, 0.898774, -3.33187, -2.09473, 2.13997, -1.20736, -1.78102, 0.661333, -2.15738, -2.82721, -0.34423, 0.945198, -1.3919, 2.24165, -1.72333, -3.61333, 0.177856, -0.499845, 1.08322, -0.57797, 1.32396, -0.580476, -0.990233, 3.13608, 0.2254, 2.44513, -1.43021, -2.20293, -0.0295935, 3.9359, 0.872028, 2.94495, 2.3334, -1.4539, -2.0155, 1.90474, -1.83284, -3.6983, -0.223583, -2.19197, 2.98892, 2.11877, -0.614374, 0.860207, 3.63726, -1.54793, 0.699044, -3.31199, -2.87789, 3.21311, -3.24507, -0.0689166, 0.225146, -2.84127, -3.67944, 0.763724, -3.93721, -3.81518, -1.06853, 0.726999, 0.562243, 3.79879, 3.75762, 2.1455, 2.00329, -0.400098, -1.80113, 3.49374, 3.26726, -1.24347, 2.0535, 2.55697, 0.670452, -2.79004, 1.39668, 2.32366, -2.27311, -0.352436, -2.71256, -2.31389, -2.11829, 0.111656, -1.67798, 2.97944, -3.7505, -1.88802, 3.50199, 1.31453, 3.32241, -1.04754, -3.03124, 1.60895, 1.15746, 2.29443, 3.31704, -0.172815, 2.81695, 0.253896, 0.298466, -3.90939, -2.39831, 3.46711, 2.41166, 2.03439, 0.387814, -3.40236, -3.71227, -1.68499, -3.81028, 2.97335, 3.32693, -3.88281, -2.61789, -3.31616, 2.71789, 3.05144, -0.579528, -0.672907, 2.75653);quartz(width=4, height=4, type="pdf", file="~/Desktop/testpdf.pdf");plot(x=x, y=y, xlim=c(-5, 5), ylim=c(-5, 5), pch=19, cex=0.5, main="2000");dev.off();}’
>>
>>  If I execute the R code that is in the -e argument directly in R GUI (on OS X) it works fine.  And if I put that code in a file and run Rscript <file>, it works fine.  So the length limit is not intrinsic to R’s parser, it would seem.  But if I try to execute exactly the same code in an interactive R session in my Unix terminal's command line, I get a continuation prompt, +, and a little investigation indicates that the input line may have been truncated after 3843 characters (a strange number) and it is waiting for more input to follow that truncated input.  And – what is most relevant for my situation – if I try to run the full Rscript command as given above (inside /bin/sh), it prints out:
>>
>> WARNING: '-e {x~+~<-~+~c(-1.31171,~+~-0.686165,~+~1.62771,~+~0.320195,~+~-0.322011,~+~1.66518,~+~-0.271971,~+~-0.665367,~+~0.516482,~+~-0.716343,~+~-0.317471,~+~0.068046,~+~-0.100371,~+~-1.15907,~+~0.263329,~+~-0.936049,~+~-0.852444,~+~0.358817,~+~-0.233959,~+~0.209891,~+~-0.831575,~+~-0.952987,~+~-0.0420206,~+~-1.78527,~+~-0.280584,~+~-0.62353,~+~1.42597,~+~0.127994,~+~0.0751232,~+~0.896835,~+~-0.319488,~+~0.897876,~+~0.18457,~+~0.779571,~+~-0.0543194,~+~0.226722,~+~-0.769983,~+~-0.723463,~+~0.144386,~+~-0.468544,~+~-0.349417,~+~0.336786,~+~0.749212,~+~-1.62397,~+~0.683075,~+~-0.746449,~+~0.300921,~+~-0.365468,~+~0.548271,~+~1.13169,~+~-1.34042,~+~-0.0740572,~+~1.34986,~+~0.531771,~+~-0.147157,~+~0.824894,~+~-1.05816,~+~1.58867,~+~-0.885764,~+~1.11912,~+~0.361512,~+~1.77985,~+~0.585099,~+~-1.205,~+~2.44134,~+~-0.331372,~+~-0.346322,~+~0.0535267,~+~-1.75089,~+~0.0773243,~+~-1.07846,~+~-1.29632,~+~1.0622,~+~1.34867,~+~0.199777,~+~0.197516,~+~0.574185,~+~1.06555,~+~-0.885166,~+~-0.788576,~+~-1.46061,~+~-1.5402
>>
>> and then it hangs – the full warning doesn’t complete printing, so it is not clear what it is trying to warn about.  That represents 844 characters of input script, but with the weird way that spaces have been replaced by ~+~ by somebody, it is 1013 characters – suspiciously close to 1024.
>>
>>  Note that if I simply make the R script shorter, by plotting 100 x/y values instead of 500, everything works fine.  So there is no issue with the way that I’m quoting strings or anything like that; the only issue seems to be the total length of the command line.
>>
>>  Now of course I could break up the script into multiple chunks, passed via separate -e arguments, and perhaps that would work somewhat better.  But given that I want to set up a vector x with a single c() command containing all of the data for x, I will still hit a line length limit; the single line of code to set up x will already be over the maximum line length that Rscript allows for a -e argument, apparently.  Getting around that would obviously be possible too, but would be considerably more hassle.
>>
>>  And incidentally, this seems to have nothing to do with the /bin/sh input line limit; that is much higher.  According to "getconf ARG_MAX”, it is 262144 characters on my machine, which is more than enough headroom for what I’m trying to do.
>>
>>  So my questions are: (1) is this a bug, (2) if so, do you think you are likely to fix it any time soon :->, and (3) if the answer to that is no, are there any standard workarounds for this sort of situation that you would recommend?  I suppose I could write out the script to a file and then execute that file with Rscript, since that seems to work; but I was really hoping to avoid that extra complication and overhead.  Is there a better way?
>>
>>  Thanks for any help you can provide!  :->
>>
>> Cheers,
>> -B.
>>
>> Benjamin C. Haller
>> Messer Lab
>> Cornell University
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> Ben Tupper
> Bigelow Laboratory for Ocean Sciences
> 60 Bigelow Drive, P.O. Box 380
> East Boothbay, Maine 04544
> http://www.bigelow.org
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Maximum length for a -e argument to Rscript?

Ben Haller-2
  OK, thanks for the information Ben and Henrik.  It sounds like even if the Rscript stall were fixed, there would still be a 10k limit when using -e, as well as a 4K maximum line length limit when using -e or stdin, if I understand the section cited by Ben; so I need to switch to using a script file instead, to get past these various limits, I guess.  Thanks for your help.

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University


> On Apr 22, 2017, at 6:59 AM, Henrik Bengtsson <[hidden email]> wrote:
>
> That Rscript stalls sounds like a bug, but not sure it's R or the
> terminal that needs to be fixed:
>
>  Rscript -e "$long_expression"
> WARNING: '-e {x~+~<-~+~c(-1.31171,~+~-0.686165,~+~1.62771,~+~0.320195,~+~-0.322011,~+~1.66518,~+~-0.271971,~+~-0.665367,~+~0.516482,~+~-0.716343,~+~-0.317471,~+~0.068046,~+~-0.100371,~+~-1.15907,~+~0.263329,~+~-0.936049,~+~-0.852444,~+~0.358817,~+~-0.233959,~+~0.209891,~+~-0.831575,~+~-0.952987,~+~-0.0420206,~+~-1.78527,~+~-0.280584,~+~-0.62353,~+~1.42597,~+~0.127994,~+~0.0751232,~+~0.896835,~+~-0.319488,~+~0.897876,~+~0.18457,~+~0.779571,~+~-0.0543194,~+~0.226722,~+~-0.769983,~+~-0.723463,~+~0.144386,~+~-0.468544,~+~-0.349417,~+~0.336786,~+~0.749212,~+~-1.62397,~+~0.683075,~+~-0.746449,~+~0.300921,~+~-0.365468,~+~0.548271,~+~1.13169,~+~-1.34042,~+~-0.0740572,~+~1.34986,~+~0.531771,~+~-0.147157,~+~0.824894,~+~-1.05816,~+~1.58867,~+~-0.885764,~+~1.11912,~+~0.361512,~+~1.77985,~+~0.585099,~+~-1.205,~+~2.44134,~+~-0.331372,~+~-0.346322,~+~0.0535267,~+~-1.75089,~+~0.0773243,~+~-1.07846,~+~-1.29632,~+~1.0622,~+~1.34867,~+~0.199777,~+~0.197516,~+~0.574185,~+~1.06555,~+~-0.885166,~+~-0.788576,~+~-1.46061,~+~-1.5402
> ^C^C
> ^C
> ^C^C^C^C^C^C
> ^\Quit (core dumped)
>
> On my default Ubuntu 16.04 terminal, R 3.3.3 hangs and does not
> respond to user interrupts (SIGINT), but it does respond to Ctrl-\
> (SIGKILL).
>
> A workaround is to pass the expression via standard input to R, e.g.
>
> $ echo "$long_expression" | R --no-save
>
> /Henrik
>
> On Fri, Apr 21, 2017 at 11:07 AM, Ben Tupper <[hidden email]> wrote:
>> Hi,
>>
>> I suspect you are over the 10kb limit for the expression.  See
>>
>> https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Invoking-R-from-the-command-line
>>
>> Cheers,
>> Ben
>>
>>> On Apr 21, 2017, at 3:44 AM, Ben Haller <[hidden email]> wrote:
>>>
>>> Hi!  I’m attempting to use Rscript to do some automated plotting.  It is working well, except that I seem to be running into a maximum line length issue, and I’m wondering if it is a bug on your end.  Here’s an example of the command I’m trying to run:
>>>
>>> /usr/local/bin/Rscript -e '{x <- c(-1.31171, -0.686165, 1.62771, 0.320195, -0.322011, 1.66518, -0.271971, -0.665367, 0.516482, -0.716343, -0.317471, 0.068046, -0.100371, -1.15907, 0.263329, -0.936049, -0.852444, 0.358817, -0.233959, 0.209891, -0.831575, -0.952987, -0.0420206, -1.78527, -0.280584, -0.62353, 1.42597, 0.127994, 0.0751232, 0.896835, -0.319488, 0.897876, 0.18457, 0.779571, -0.0543194, 0.226722, -0.769983, -0.723463, 0.144386, -0.468544, -0.349417, 0.336786, 0.749212, -1.62397, 0.683075, -0.746449, 0.300921, -0.365468, 0.548271, 1.13169, -1.34042, -0.0740572, 1.34986, 0.531771, -0.147157, 0.824894, -1.05816, 1.58867, -0.885764, 1.11912, 0.361512, 1.77985, 0.585099, -1.205, 2.44134, -0.331372, -0.346322, 0.0535267, -1.75089, 0.0773243, -1.07846, -1.29632, 1.0622, 1.34867, 0.199777, 0.197516, 0.574185, 1.06555, -0.885166, -0.788576, -1.46061, -1.54026, 0.690576, -0.88821, 0.343747, -0.100751, -0.865596, -0.128504, 0.222334, -1.18932, -0.555258, -0.557368, 0.219272, 0.298858, 0.848022, 0.142608, 1.10082, -0.348039, 0.0566489, 0.662136, 0.50451, -0.909399, 1.02446, 1.40592, -0.114786, -1.10718, 2.02549, 0.0818607, -1.037, 1.18961, -0.204, 2.83165, -0.959653, -0.393082, -0.463351, 0.914054, 1.14472, -1.32927, 1.25416, 0.372267, 0.410832, 1.04187, 1.22288, 1.27131, 0.0949385, 0.194053, -0.226184, -0.502155, -1.36834, -0.000591861, -0.565903, 1.14099, 1.67811, 0.331709, -0.756879, 0.889596, 0.718098, 0.740242, -0.861818, 0.0332746, 1.01745, 0.584536, -1.14245, -0.444485, -1.34237, 0.660603, 1.16048, -0.898828, 0.965746, -1.16953, -2.33417, 0.591078, -0.364892, 0.0719267, -1.21676, 1.12646, 1.37534, 0.0712832, 1.22889, -0.0110024, 0.248213, -1.12013, -0.525197, -0.352156, -0.317182, -0.89552, 1.53422, -1.36777, 1.52099, 1.18789, -3.15251, 1.24008, -0.564289, -0.515629, -0.0920464, 2.94027, 0.895481, -0.157643, -0.347874, -0.290823, -0.771436, 1.29285, 0.216689, -1.86856, 2.24075, 0.888635, 0.430417, -0.585856, 1.13119, -0.243977, 0.544491, 0.921995, 0.815365, 1.2584, -1.29347, 0.0574579, 0.990557, -1.58657, -0.264373, 0.865893, 0.599298, -0.417531, 0.132897, 1.88597, 1.33112, -0.880904, 0.0762161, 0.0567852, 0.593295, -0.632135, 0.885625, 0.365863, -0.17885, 0.420185, -0.508275, 0.974357, 0.628085, 0.710578, 1.72447, 1.38488, 1.01301, 1.30015, 0.260501, 0.808981, 0.440228, 0.416344, -1.66273, -0.397224, -0.512086, -0.175854, -0.663143, 0.369712, -1.01654, 0.660465, 0.124851, -1.51101, -0.95725, 2.09893, 1.26819, 1.08086, 0.493204, 0.79073, 1.49191, 0.563689, 0.414473, 2.27361, 0.871923, 0.193703, -0.185039, -0.312859, -1.42267, -2.11561, 0.311996, -0.0906527, 1.19139, 1.57502, 1.10587, 0.416333, 2.35374, -1.0531, 0.0450512, 0.979958, 0.398269, 0.0897618, -0.855305, -1.59337, -0.084904, 0.245872, 1.27115, 1.3512, -0.166962, 1.01098, -1.19854, -2.05932, -0.98, 0.704973, 0.694688, 1.20408, -1.12553, 0.770056, 1.01602, 0.295223, -1.18801, 1.51707, 1.1418, -0.148787, 1.28886, 1.23981, 1.67984, 0.0185941, -0.877581, 0.495042, -0.368668, 1.59972, -2.20849, -1.36852, -0.972566, -1.01848, -0.366674, -2.60273, -0.540706, -0.475797, 0.227651, -1.11476, 1.73452, -0.212185, 3.04994, -0.251225, -0.0443482, -0.489125, 0.557936, -0.246389, -0.954287, 0.388668, 0.759049, -0.501683, -1.98722, 0.158712, -0.897082, -1.17644, 0.192465, -1.49901, -0.289129, -0.0460198, -0.520331, 0.432488, -0.471775, 1.21482, 0.998091, -0.794933, -0.36989, 0.937091, 1.27297, 1.06108, -0.784307, 0.70919, -0.309221, -0.516031, 0.479702, -0.669637, 1.60288, 0.657474, -0.666286, -1.01816, -0.452818, -0.283749, 1.05511, -1.2002, 0.112269, -1.37403, 1.00512, 0.664936, 0.600516, -1.08099, -0.705522, 0.103051, 0.0461179, 1.74404, 0.727475, 2.41175, 1.20414, 1.71095, 0.0957544, 0.610755, 0.545194, -0.936381, 0.190467, 0.485791, 0.0855697, 0.142676, 0.721754, -1.84506, 2.1227, -1.1271, -1.11228, -1.2807, 0.13385, 0.228727, -0.34391, 1.09837, -0.37053, 0.832574, 0.673463, 0.717732, -0.307687, 1.12486, 0.159803, -1.51251, 1.403, 2.0215, 0.010914, -0.543749, 0.137119, 0.200364, -0.104029, -0.930966, -1.56781, -0.526978, -0.537582, 1.11872, -0.99061, -0.501421, 1.21982, 0.813201, -0.539109, 0.433523, -0.0615188, 2.04298, 0.697692, 1.34515, 1.7298, 0.515137, 2.08119, 0.550985, 1.49876, 1.31187, 0.920405, 0.597678, 0.884353, -0.732892, -0.143545, -0.236836, -0.330872, 1.55577, -1.74473, -0.493322, 1.46375, 1.14347, 1.76164, 1.73099, -0.234701, -0.0546848, 0.346991, -0.393301, 1.34267, -1.58519, -0.381789, 0.622675, 1.34655, 2.84895, -0.371, -0.519666, -1.64944, 0.573592, 1.06484, -0.0239894, -0.604563, 0.0680641, -0.881325, 1.07265, 0.182585, 0.373288, 2.20228, -0.763593, -0.25659, 1.9397, -0.166943, -0.672522, -1.35983, 0.227406, 0.49471, -1.23535, -0.479552, 1.97798, 0.418181, 1.23454, -0.0767748, 0.828642, -0.0348468, -0.264499, 0.76699, -0.910363, -2.11408, -0.209169, 0.902191, -2.27096, 0.098513, -0.380699, -0.231276, -0.0296834, 0.834972, -0.658283, 0.616493, 0.198916, -1.89783, -1.30219, 0.51036, 0.195825, -1.68961, -1.27838, 0.879616, 0.566719, 1.21876, 0.270402, -1.38261, 0.365878, 1.54191, 1.25104, 1.23067, 1.87261);y <- c(0.986442, 2.65684, -1.79726, 1.79999, -2.43971, -1.68358, -1.84081, -2.27973, 2.96046, 2.61837, 1.48756, 1.63497, 1.46876, 2.09348, -0.925101, 3.6792, -2.03618, 1.33232, -0.0652269, 0.809911, -2.82019, -1.87691, 1.1284, 0.249619, -2.94777, 3.00423, -2.79901, -0.110801, -3.546, 1.67156, -3.10723, -3.24205, 3.16911, -3.24227, -1.29801, 0.271933, -2.83573, -0.79973, -2.34429, -0.905163, -0.197905, -3.05664, -0.694481, 1.89301, -2.70264, 2.94361, -2.32469, 1.9576, 1.73556, -3.29777, -1.54311, -2.03172, -0.871756, 0.77581, 3.7692, 1.54446, 3.92129, 0.160296, -3.45486, -1.56317, -2.72913, 0.695854, 3.15786, 1.1006, 3.25649, -1.57206, -3.15353, 0.242301, -1.95855, -0.256919, 3.04782, -0.505045, -2.35542, 2.11649, -1.73363, 2.65149, 3.66302, 0.457907, -2.2759, -2.36105, -2.49263, -2.9784, -3.53525, -0.699404, 3.17647, -1.52424, 2.72699, 3.82774, 0.100029, 3.42107, 1.74672, 3.1279, -0.793162, -0.025109, 1.07262, 2.4517, -2.00605, -3.6625, -2.57031, -2.43599, 2.56309, -1.31707, -2.10777, -3.75394, 0.954311, 0.496025, 3.82545, -3.74259, -1.96145, 0.366455, 3.97474, 3.26111, -3.69904, 2.07392, 0.591191, -3.34162, -0.926126, 1.03966, -2.68754, -2.69653, 0.651845, 2.82333, 2.25596, 3.26545, -2.57379, 2.69137, -3.08119, 2.99114, -3.86005, -1.30995, 1.80096, 1.39404, -2.6482, -2.12922, -3.28834, -1.06563, -1.6683, -2.023, 1.60516, -1.67431, 1.38595, 0.287423, 2.56888, -2.99169, 0.549401, 2.31817, -2.48251, 2.20152, 1.0531, -3.60478, 0.327999, 0.475523, -0.454324, -2.63147, -1.61249, -1.65507, 1.13203, 0.218, 2.87289, -0.279036, -0.316795, 3.22757, -2.25, -1.10923, 0.0949814, -2.60818, -0.181803, 3.65484, 2.86193, 0.940815, 3.5461, 1.23983, 2.01177, -0.428626, 3.5539, -2.63454, 1.63098, 3.69696, 0.404995, 0.480342, 3.22724, -3.57127, -2.38176, -1.23267, 0.738668, 1.64966, 1.37331, -2.60132, -1.60081, 2.57359, -3.58266, 1.32347, 3.24265, 3.81, 3.90706, -0.407994, 2.42083, 3.34477, 3.43151, -1.08974, -2.93732, 2.39014, -1.36511, -0.101514, -1.46445, 2.11849, -3.63955, -1.57038, 3.41777, -1.00185, -0.0702487, 2.01317, -3.38133, 3.64754, -0.740182, -3.64028, -3.77238, 2.45613, -3.11631, 3.82543, 2.15285, -0.790691, -1.22153, -0.943069, -3.37327, 1.19097, 1.48834, 0.502127, -2.90383, -3.4236, -0.676889, 3.41785, 2.54728, -2.60006, -3.25969, -1.85346, -2.8088, 3.3905, -1.34015, -1.3877, 2.38485, 3.16688, -3.26326, -1.94801, 0.0878641, 0.492529, 2.62313, -2.08994, -1.77721, 1.92357, 0.739532, 0.869021, -3.82981, 3.92422, -1.16293, 3.82139, -1.67119, 1.1145, -2.24382, -1.93777, -0.109559, -0.350947, 1.94832, -2.54192, 1.224, 0.797731, 0.767982, -2.93565, -2.72896, 1.2624, 1.91513, -3.96412, 3.43534, 0.358804, 3.05541, -0.213663, 0.38204, -0.539063, -0.897154, -2.91298, -0.198784, -0.0732228, 2.99983, 3.54078, 2.27245, 3.87904, 2.99445, -0.705307, 0.187173, 1.79102, 1.69581, 2.08613, 1.54021, 0.7471, -1.19008, 2.44732, -1.59312, 1.5387, -0.526756, 3.06958, -1.707, -2.46148, -0.523427, -0.675584, -3.02611, -2.22116, -3.4546, -2.94353, 2.1346, 3.51197, 1.85137, 1.7461, -0.875901, -2.13891, -2.1714, 1.6953, -0.159958, 1.77583, -0.808156, 2.04446, 3.58507, -1.27303, -0.0739294, 0.22885, -1.16883, -0.0437807, -1.30141, 2.71702, 2.85379, 3.74969, 3.5839, -0.159889, -0.236555, 2.78411, 2.15217, -0.945737, -1.90692, 0.536403, -1.08419, -3.75986, 2.65243, -2.29661, 3.8776, 1.23146, -2.26545, 2.79205, 2.34152, -3.62388, -3.51983, -0.152083, -0.77672, -0.0661756, -1.12531, 1.77691, -1.49266, -0.401453, -2.98782, 1.15182, 3.00211, -0.338523, 2.63385, -1.30166, -1.96304, -2.03665, -2.91373, 3.33512, 0.26508, -2.4008, -0.989122, -1.96516, 0.498154, -0.139963, 1.762, -0.36494, 2.42886, 1.26076, -0.344707, -2.2629, 3.01517, -0.192693, 1.72579, -3.09541, 0.898774, -3.33187, -2.09473, 2.13997, -1.20736, -1.78102, 0.661333, -2.15738, -2.82721, -0.34423, 0.945198, -1.3919, 2.24165, -1.72333, -3.61333, 0.177856, -0.499845, 1.08322, -0.57797, 1.32396, -0.580476, -0.990233, 3.13608, 0.2254, 2.44513, -1.43021, -2.20293, -0.0295935, 3.9359, 0.872028, 2.94495, 2.3334, -1.4539, -2.0155, 1.90474, -1.83284, -3.6983, -0.223583, -2.19197, 2.98892, 2.11877, -0.614374, 0.860207, 3.63726, -1.54793, 0.699044, -3.31199, -2.87789, 3.21311, -3.24507, -0.0689166, 0.225146, -2.84127, -3.67944, 0.763724, -3.93721, -3.81518, -1.06853, 0.726999, 0.562243, 3.79879, 3.75762, 2.1455, 2.00329, -0.400098, -1.80113, 3.49374, 3.26726, -1.24347, 2.0535, 2.55697, 0.670452, -2.79004, 1.39668, 2.32366, -2.27311, -0.352436, -2.71256, -2.31389, -2.11829, 0.111656, -1.67798, 2.97944, -3.7505, -1.88802, 3.50199, 1.31453, 3.32241, -1.04754, -3.03124, 1.60895, 1.15746, 2.29443, 3.31704, -0.172815, 2.81695, 0.253896, 0.298466, -3.90939, -2.39831, 3.46711, 2.41166, 2.03439, 0.387814, -3.40236, -3.71227, -1.68499, -3.81028, 2.97335, 3.32693, -3.88281, -2.61789, -3.31616, 2.71789, 3.05144, -0.579528, -0.672907, 2.75653);quartz(width=4, height=4, type="pdf", file="~/Desktop/testpdf.pdf");plot(x=x, y=y, xlim=c(-5, 5), ylim=c(-5, 5), pch=19, cex=0.5, main="2000");dev.off();}’
>>>
>>> If I execute the R code that is in the -e argument directly in R GUI (on OS X) it works fine.  And if I put that code in a file and run Rscript <file>, it works fine.  So the length limit is not intrinsic to R’s parser, it would seem.  But if I try to execute exactly the same code in an interactive R session in my Unix terminal's command line, I get a continuation prompt, +, and a little investigation indicates that the input line may have been truncated after 3843 characters (a strange number) and it is waiting for more input to follow that truncated input.  And – what is most relevant for my situation – if I try to run the full Rscript command as given above (inside /bin/sh), it prints out:
>>>
>>> WARNING: '-e {x~+~<-~+~c(-1.31171,~+~-0.686165,~+~1.62771,~+~0.320195,~+~-0.322011,~+~1.66518,~+~-0.271971,~+~-0.665367,~+~0.516482,~+~-0.716343,~+~-0.317471,~+~0.068046,~+~-0.100371,~+~-1.15907,~+~0.263329,~+~-0.936049,~+~-0.852444,~+~0.358817,~+~-0.233959,~+~0.209891,~+~-0.831575,~+~-0.952987,~+~-0.0420206,~+~-1.78527,~+~-0.280584,~+~-0.62353,~+~1.42597,~+~0.127994,~+~0.0751232,~+~0.896835,~+~-0.319488,~+~0.897876,~+~0.18457,~+~0.779571,~+~-0.0543194,~+~0.226722,~+~-0.769983,~+~-0.723463,~+~0.144386,~+~-0.468544,~+~-0.349417,~+~0.336786,~+~0.749212,~+~-1.62397,~+~0.683075,~+~-0.746449,~+~0.300921,~+~-0.365468,~+~0.548271,~+~1.13169,~+~-1.34042,~+~-0.0740572,~+~1.34986,~+~0.531771,~+~-0.147157,~+~0.824894,~+~-1.05816,~+~1.58867,~+~-0.885764,~+~1.11912,~+~0.361512,~+~1.77985,~+~0.585099,~+~-1.205,~+~2.44134,~+~-0.331372,~+~-0.346322,~+~0.0535267,~+~-1.75089,~+~0.0773243,~+~-1.07846,~+~-1.29632,~+~1.0622,~+~1.34867,~+~0.199777,~+~0.197516,~+~0.574185,~+~1.06555,~+~-0.885166,~+~-0.788576,~+~-1.46061,~+~-1.5402
>>>
>>> and then it hangs – the full warning doesn’t complete printing, so it is not clear what it is trying to warn about.  That represents 844 characters of input script, but with the weird way that spaces have been replaced by ~+~ by somebody, it is 1013 characters – suspiciously close to 1024.
>>>
>>> Note that if I simply make the R script shorter, by plotting 100 x/y values instead of 500, everything works fine.  So there is no issue with the way that I’m quoting strings or anything like that; the only issue seems to be the total length of the command line.
>>>
>>> Now of course I could break up the script into multiple chunks, passed via separate -e arguments, and perhaps that would work somewhat better.  But given that I want to set up a vector x with a single c() command containing all of the data for x, I will still hit a line length limit; the single line of code to set up x will already be over the maximum line length that Rscript allows for a -e argument, apparently.  Getting around that would obviously be possible too, but would be considerably more hassle.
>>>
>>> And incidentally, this seems to have nothing to do with the /bin/sh input line limit; that is much higher.  According to "getconf ARG_MAX”, it is 262144 characters on my machine, which is more than enough headroom for what I’m trying to do.
>>>
>>> So my questions are: (1) is this a bug, (2) if so, do you think you are likely to fix it any time soon :->, and (3) if the answer to that is no, are there any standard workarounds for this sort of situation that you would recommend?  I suppose I could write out the script to a file and then execute that file with Rscript, since that seems to work; but I was really hoping to avoid that extra complication and overhead.  Is there a better way?
>>>
>>> Thanks for any help you can provide!  :->
>>>
>>> Cheers,
>>> -B.
>>>
>>> Benjamin C. Haller
>>> Messer Lab
>>> Cornell University
>>>
>>> ______________________________________________
>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>> Ben Tupper
>> Bigelow Laboratory for Ocean Sciences
>> 60 Bigelow Drive, P.O. Box 380
>> East Boothbay, Maine 04544
>> http://www.bigelow.org
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Loading...