Re: qx() won't accept over (about) 128,000 characters



Jameson C. Burt wrote:
Within Perl, I construct programs in other programming languages
and submit the result to a Unix (Linux or IBM AIX) operating system
with 2GB to 8GB memory.
I submit such a program to the operating system using Perl's
qx()
Unfortunately, giving qx() over 128,420 characters (about and can vary
by a few characters) then returns nothing.
Yet, giving qx() 128,000 characters gets properly executed by the
operating system.

Following is an example,
expedited from my original test that actually had 1270 lines.
Only with fewer lines (eg, replace 1370 by 1269) will this program output
"Last line of large program!"
Here's the program that constructs
and tries giving qx() over 128,000 characters of code:
#!/usr/bin/perl -w
$shorty = ' ' x 99 . '#' . "\n" ; #100/101 characters
#Repeat 1370 lines of $shorty into @manylines:
# foreach $i (0..1269) {$manylines[$i] = $shorty} ; #Succeeds
foreach $i (0..1370) {$manylines[$i] = $shorty} ;
$manylines[$#manylines + 1] = 'echo "Last Line of large program!"' ;

You can simplify that to:

my @manylines = ( ( ' ' x 99 . "#\n" ) x 1371, 'echo "Last Line of large
program!"' );


print qx(@manylines) ;
# system(qq(@manylines)) ; #Same problem.

Your line of code is a comment (The # character starts a comment in shell)
which is why nothing is returned:

$ perl -e'
my @manylines = ( ( " " x 99 . "#\n" ) x 1371, q[echo "Last Line of large
program!"] );
print qx[@manylines];
' | wc
0 0 0
$ perl -e'
my @manylines = ( ( " " x 99 . "\n" ) x 1371, q[echo "Last Line of large
program!"] );
print qx[@manylines];
' | wc
1 5 28
$ perl -e'
my @manylines = ( ( " " x 99 . "\n" ) x 1371, q[echo "Last Line of large
program!"] );
print qx[@manylines];
'
Last Line of large program!


However, appending the following lines to the above code
will properly execute those 1370 lines.
open(OUTFILE, ">/tmp/zz.out") ;
print(OUTFILE @manylines) ;
close(OUTFILE) ;
system("bash /tmp/zz.out") ;
While I can run this latter code, it both adds more code
and adds a file to the operating system's filesystem.

Can qx() accept large numbers of characters,
perhaps using some simple technique?

When it is saved as a file the shell (bash) ignores the comment lines.



John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.



Relevant Pages

  • Re: qx() wont accept over (about) 128,000 characters
    ... and submit the result to a Unix operating system ... I submit such a program to the operating system using Perl's ... Unfortunately, giving qxover 128,420 characters (about and can vary ... $ perl -e' ...
    (perl.beginners)
  • Re: Problem with scanf()/gets()
    ... However, in such cases, it would not be the *operating system* that ... input device's inability to produce additional characters. ... limited input size -- not since the mid 80's, ... with IBM terminals that were FEP ...
    (comp.lang.c)
  • Re: Decimals
    ... Actually, TeX-78 was written on the WAITSoperating system, ... characters, as the need arose. ... seven shift keys (shift, control, meta, alt, super, hyper, and ... or all of shift, control, meta, super, hyper, or symbol. ...
    (alt.usage.english)
  • Re: Moving shared folders & preserving permissions
    ... The limitation of 256 characters is imposed by the operating system, ... robocopy is subject to it in the same way as ... Use xcopy.exe to copy the folders. ...
    (microsoft.public.windows.server.general)
  • Re: Printer only putting out lines of random letters/characters
    ... Was the operating system recently changed? ... (letters, numbers, dots, non-keyboard characters), often only one line ...
    (microsoft.public.windowsxp.print_fax)