Hi,

I'm writing an application which pipes data from mkisofs to cdrecord under Unix. Unfortunatley, I have to do this without the shell interpreting weird characters in the filenames which I'm passing to the script, so I have to use safe pipe opens. So far, I've written the following code to do this:

use POSIX qw(sys_wait_h); use strict; ... if ($cdrpid = open(CDREC, "|-")) { if ($isopid = open(MKISO, "-|")) { my ($rin, $nfd) = ("",""); vec($rin, fileno(CDREC), 1) = 1; if (not($nfd = select($rin, $rin, undef, 20))) { die "argh timeout"; } while (<MKISO>) { print CDREC; } close(MKISO); } else { exec "$OPT{isobin}", '-r', @ARGV; } close(CDREC); } else { exec "$OPT{cdbin}", "speed=$OPT{speed}", dev=$OPT{dev}", "tsize=@t +size", '-waiti', '-data', '-'; } waitpid($isopid, &WNOHANG); waitpid($cdrpid, &WNOHANG);
Okay, it sucks but it more or less works. I have two problems with this current implemenation, however:

1) I would like to be able to optionally pipe the data from mkisofs to aespipe and then to cdrecord to facilitate creating encrypted CD-Rs. Right now I can't really think of a good way to do this.

2) This program is going to eventually have a frontend, so I'm going to need to read status information printed from mkisofs to STDERR to update a progress bar thingy. I'm not really sure of what the best way to do this would be either.

Any ideas would be appriciated.


In reply to Mysteries of IPC... by j0e

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.