[Wellington-pm] pass-through pipe?

Daniel Pittman daniel at rimspace.net
Sun Jul 18 18:00:54 PDT 2010


Grant McLean <grant at mclean.net.nz> writes:
> On Sun, 2010-07-18 at 18:13 +1200, Richard Hector wrote:
>> On Sun, 2010-07-18 at 17:06 +1200, Lenz Gschwendtner wrote:
>> > you mean something other than one process prints to STDOUT and the other
>> > one reading from STDIN ...
>> > 
>> > not sure i get your question right but if you need something other than
>> > the normal stuff then you might be after a FIFO buffer? shared memory?
>> > what is the use case? probably that helps :-)
>> 
>> The use case is encrypting postgresql backups:
>> 
>> system "pg_dump --cluster $cluster --dbname $dbname ... | gpg
>> --options ... --encrypt";
>> 
>> Currently I'm doing that in one 'system' line as described, but that
>> fires up a shell, which shouldn't be necessary?
>
> I guess strictly speaking, the shell is not necessary and yes you could
> implement it using Perl's builtin pipe, fork, exec and wait.  But frankly
> why bother?

...because you don't want to suddenly discover problems tomorrow, when Debian
change /bin/sh from bash to dash, cutting out a whole lot of bash-specific
features, and your key client refuses to change it back to suit you?

I know, if you get it right the first time that isn't a problem, and in this
trivial case that is pretty standard, but it does mean that your script now
includes the behaviour of /bin/bash in the spec.

(Plus, you lose the ability to test return codes from anything but the last
 process, which the OP mentioned as desirable-but-not-mandatory.)


Anyway, all that said, just use IPC::Run.  Someone already did the work of
making this as easy as doing it with system and /bin/sh, so you can avoid
reinventing that particular wheel.

        Daniel

...or use one of the other modules that does the same thing.  This isn't
rocket science, and has been solved on CPAN for ages.
-- 
✣ Daniel Pittman            ✉ daniel at rimspace.net            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons


More information about the Wellington-pm mailing list