Hi Barrie,
I dug out an old note from you and started trying IPC::Run. Here's what I
have so far:
sub MP3Check {
my ($self,$params) = @_;
use IPC::Run qw( run timeout );
my @command = (
$self->{MP3Check},
qq! -v "$params->{file}"!
);
run [EMAIL PROTECTED], \undef, \my $output, timeout( 5 ) or die "mp3_check: $?";
my @outlines = split /\n/, $output;
my %values;
for ( @outlines ) {
$values{$1} = $2 if /^([A-Z_]+)\s+(.*)$/;
}
return \%values;
}
Something is wrong with the command line... Seems like no matter what I try,
I get file not found... The files do exist and I'm calling the package from
a test script ran as root.
Above, $self->{MP3Check} evaluates to: /home/rw/bin/mp3_check
$params->{file} is one of these (without quotes):
"/media/New/Music/Albums/sting.mp3"
"/media/New/Music/Albums/sting - angel eyes (2).mp3"
"/media/New/Music/Albums/The Soggy Bottom Boys - Man Of Constant Sorrow.mp3"
"/media/New/Music/Albums/Various Artists - O Death.mp3"
"/media/New/Music/Albums/2Pac-Better_Dayz-2CD-2002-RNS/Disc
1/2pac-104-changed_man-rns.mp3"
So a valid command is: /home/rw/bin/mp3_check -v
"/media/New/Music/Albums/sting.mp3"
This works for IPC::Open3
my $command = qq!$self->{MP3Check} -v "$params->{file}"!;
How should it be done with IPC::Run?
Also, with IPC::Open3, I am killing the process in the alarm and setting a
variable to indicate check failed:
$SIG{ALRM} = sub {
my $kill = "kill -9 $pid";
system($kill);
$values{'CHECK_PROBLEM'} = 1;
return;
};
How would something similar be done with IPC::Run?
Thanks alot for your help!
Cameron