merlyn@iwarp.intel.com (Randal Schwartz) (09/09/89)
In article <680@lakart.UUCP>, dg@lakart (David Goodenough) writes: | OK - will you all get off my case, already!! [awk program deleted] And, here it is in Perl (of course...)... ================================================== cut here #!/usr/bin/perl $lengthmax = 512; @command = $#ARGV > -1 ? @ARGV : ("/bin/echo"); $lengthcommand = length(join(" ", @command)) + 1; while (<stdin>) { if ($lengthcommand + length($args) + length($_) > $lengthmax) { system @command, split(/\n/, $args); $err = 1 if $?; $args = ""; } $args .= $_; } if (length($args)) { system @command, split(/\n/, $args); $err = 1 if $?; } exit $err; ================================================== cut here too This version handles commands with *any* special characters (provided you had already quoted it for the shell properly), and arguments with any characters *except* newline (gotta have *one* reserved character :-). | So there :-P Like I said, I do it all with awk :-) And, I do it all with Perl, now. Just another Perl hacker, -- /== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\ | on contract to Intel, Hillsboro, Oregon, USA | | merlyn@iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn | \== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/