Hello- Great site, thanks for the help... :)
Anyway, I am in the process of writing a Perl script to create a pipe, read a file list, and pass each file name in the list to the pipe with some selectable delay between sending the file names to the pipe. Another program is called which is set up to read and open the filenames from the pipe and then do some processing on the file it opens. Everything works great if I manually create the pipe by:
$ mknod named.pipe p
$ cat >> named.pipe
and enter the filenames into the pipe by typing the name in the terminal followed by a carriage return, but I can't figure out why this script below isn't doing the job.
It happens that the first file name is put in the pipe, then it is put in immediately again, then the program to read the pipe dies without any error given. Here is the relevant code snippet:
#!/usr/bin/perl -w
# Set parameters here
$obs_file_dir = "/some/path/";
$wait_time = 30;
# Read observed file names to array
$obs_file_list = $obs_file_dir . "file_list.txt";
open(DIR, $obs_file_list) || die("Could not open file!");
@obs_files = <DIR>;
close(DIR);
# Start program to read pipe and process data
system("otherProgramToReadPipe");
# Open pipe
system("mknod named.pipe p");
foreach $file (@obs_files)
{
open(FIFO, ">> named.pipe");
print FIFO $obs_file_dir . $file;
close(FIFO);
sleep $wait_time;
}
close(FIFO);
Thank you for your thoughts!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.