From: lbo_user on
On 27 Nov, 21:06, "J. Gleixner" <glex_no-s...(a)qwest-spam-no.invalid>
wrote:

> Hu.. permission problem? Does the file exist?
>

Not a permissions problem. The destination directory is readable and
writable by all. I can touch a file without any problems.

> > "flac" --decode --stdout "2Pac/2Pacalypse Now/01-Young Black
> > Male.flac"| lame --noreplaygain --preset standard - "/Volumes/FreeNAS/
> > MEDIA/MP3_new/2Pac/2Pacalypse Now/OwbFwjqwWP.tmp"
>
> That's the exact command that's executed?
>
> "flac" --decode ...
> ^ ^ ?????
>
> And it works perfectly when you run it from the command line?
>

Yes, that's the exact command. The script changes directory to the
source directory, so when I run it directly on the command line I just
need to add the source path as follows:

[macbaddy:~] sjalloq% "flac" --decode --stdout "/Volumes/FreeNAS/MEDIA/
FLAC/2Pac/2Pacalypse Now/01-Young Black Male.flac"| lame --
noreplaygain --preset standard - "/Volumes/FreeNAS/MEDIA/MP3_new/2Pac/
2Pacalypse Now/1jvGmLGt0G.tmp"

flac 1.1.4, Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007
Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are
welcome to redistribute it under certain conditions. Type `flac' for
details.

LAME 3.97 32bits (http://www.mp3dev.org/)
Using polyphase lowpass filter, transition band: 18671 Hz - 19205 Hz
Encoding <stdin>
to /Volumes/FreeNAS/MEDIA/MP3_new/2Pac/2Pacalypse Now/
1jvGmLGt0G.tmp
Encoding as 44.1 kHz VBR(q=2) j-stereo MPEG-1 Layer III (ca. 7.3x)
qval=3
01-Young Black Male.flac: done
[macbaddy:~] sjalloq%

And that completes without any problems also.

Ta.
From: Sherman Pendley on
lbo_user <shareef.jalloq(a)lightblueoptics.com> writes:

> Having added Sherman's code to get the actual error

Thanks for the vote of confidence, but it's not my code - I just copied it
from "perldoc -f system". :-)

> Can't init outfile '/Volumes/FreeNAS/MEDIA/MP3_new/2Pac/2Pacalypse Now/
> OwbFwjqwWP.tmp'
> child exited with value 255

That error message is from flac, not Perl. Did you ask the flac author what
it means?

sherm--

--
WV News, Blogging, and Discussion: http://wv-www.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
From: J. Gleixner on
lbo_user wrote:
> On 27 Nov, 21:06, "J. Gleixner" <glex_no-s...(a)qwest-spam-no.invalid>
> wrote:
>
>> Hu.. permission problem? Does the file exist?
>>
>
> Not a permissions problem. The destination directory is readable and
> writable by all. I can touch a file without any problems.
>
>>> "flac" --decode --stdout "2Pac/2Pacalypse Now/01-Young Black
>>> Male.flac"| lame --noreplaygain --preset standard - "/Volumes/FreeNAS/
>>> MEDIA/MP3_new/2Pac/2Pacalypse Now/OwbFwjqwWP.tmp"
>> That's the exact command that's executed?
>>
>> "flac" --decode ...
>> ^ ^ ?????
>>
>> And it works perfectly when you run it from the command line?
>>
>
> Yes, that's the exact command. The script changes directory to the
> source directory, so when I run it directly on the command line I just
> need to add the source path as follows:

And you're sure it changes directory?

What if you go to /tmp, or something, and run it with --stdout
"blah/abc.flac" (e.g. the file doesn't exist.)

Maybe you should show us the code. Simplify it, test it, and post it,
because if it runs via command line, it'll run via system, so you
obviously are doing something that's not quite right.



>
> [macbaddy:~] sjalloq% "flac" --decode --stdout "/Volumes/FreeNAS/MEDIA/
> FLAC/2Pac/2Pacalypse Now/01-Young Black Male.flac"| lame --
> noreplaygain --preset standard - "/Volumes/FreeNAS/MEDIA/MP3_new/2Pac/
> 2Pacalypse Now/1jvGmLGt0G.tmp"

You're not proving anything there. Change to the directory, you
think your program is changing to, and run the exact command
you posted as your program's output. Either that or use
the full path in your program, to ensure the path or CWD
isn't a problem.

Also, you don't need the double quotes around flac.
From: lbo_user on

> You're not proving anything there. Change to the directory, you
> think your program is changing to, and run the exact command
> you posted as your program's output. Either that or use
> the full path in your program, to ensure the path or CWD
> isn't a problem.
>
> Also, you don't need the double quotes around flac.

OK, agreed. The quotes are from the original author and I removed
them from "lame" but not from flac. I've been hacking and not keeping
up.

I'll see if I confirm which directory it is being executed in.

Thanks.
From: lbo_user on
OK, so I've got to the bottom of the problem and it's not what I would
have thought. The directory paths were all fine but when I changed
the script to use an intermediate temp file instead of using the pipe
it all started working.

The original code was:

my $convert_command = "$flaccmd @flacargs \"$quotedsrc\"" . " |
$lamecmd @lameargs - \"$tmpfilename\"";
system($convert_command);

which bailed with the error above. However, if I changed it to:

my $flacoutname = $tmpfilename . "_tmp";
my $flac_command = "$flaccmd @flacargs \"$quotedsrc\" -o
\"$flacoutname\"";
my $lame_command = "$lamecmd @lameargs \"$flacoutname\"
\"$tmpfilename\"";
system($flac_command);
system($lame_command);
unlink $flacoutname;

everything was fine. What is it about that concatenation with the
pipe command that is wrong when used within Perl's system?