On Fri, Jul 18, 2003 at 01:18:12PM -0500, Cameron B. Prince wrote: > 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...
I'd do a use BFD; [EMAIL PROTECTED]; to see what it's Really Doing. I think, however, that you'd see something like: [ '/home/rw/bin/mp3_check', ' -v "/media/New/Music/Albums/sting.mp3"', ], which is probably not what you want. The program name is ok, but you're attempting to pass two parameters and some shell-oriented quotation marks through a non-shell spawning operation so mp3_check is receiving a single parameter string it can't parse. The upside is that you're not causing the overhead of spawning a shell or the parse errors that will occur if some sneaky feller puts a shell metacharacter in an mp3 filename :). I think you want @command to look like: ( '/home/rw/bin/mp3_check', '-v', '/media/New/Music/Albums/sting.mp3', ), and so you'd build @command like so: my @command = ( $self->{MP3Check}, '-v', $params->{file}, ); > 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? User Perl's exception handling mechanism, roughly like so: eval { run [EMAIL PROTECTED], \undef, \$out, timeout( 5 ) or die "$self->{MP3Check} returned ", $? >> 8, "\n"; 1; } or do { ## check $@ here for either your die() call or for ## IPC::Run::run()'s timeout exception. }; - Barrie