From: lbo_user on
Hi all,

I've had a look around but haven't managed to find any info on this
particular problem. Maybe I was searching for the wrong stuff.
Anyway, I have a script that runs the flac and lame tools to convert
between FLAC and MP3.

Within the script the variable $convert_command contains the full
piped command with file pathnames etc. This is called using system()
but it always fails with exit code 65280 and the warning, "Can't init
outfile 'my_outfile'". However, when I run the same command from the
shell everything is fine and the file is written. The destination is
writable by all. There don't seem to be any permissions problems.
What am I missing?

Thanks.
From: xhoster on
lbo_user <shareef.jalloq(a)lightblueoptics.com> wrote:
> Hi all,
>
> I've had a look around but haven't managed to find any info on this
> particular problem. Maybe I was searching for the wrong stuff.
> Anyway, I have a script that runs the flac and lame tools to convert
> between FLAC and MP3.
>
> Within the script the variable $convert_command contains the full
> piped command with file pathnames etc. This is called using system()
> but it always fails with exit code 65280 and the warning, "Can't init
> outfile 'my_outfile'". However, when I run the same command from the
> shell everything is fine and the file is written. The destination is
> writable by all. There don't seem to be any permissions problems.
> What am I missing?

You are missing the Perl code that shows us what you are doing.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
From: Sherman Pendley on
lbo_user <shareef.jalloq(a)lightblueoptics.com> writes:

> Within the script the variable $convert_command contains the full
> piped command with file pathnames etc. This is called using system()
> but it always fails with exit code 65280 and the warning, "Can't init
> outfile 'my_outfile'". However, when I run the same command from the
> shell everything is fine and the file is written. The destination is
> writable by all. There don't seem to be any permissions problems.
> What am I missing?

The error message isn't a Perl error - it's coming from the tools you're
calling. Without seeing your code it's difficult to do more than guess,
but one thing I would do is double-check the value of $convert_command,
to make absolutely certain it's right. With Perl and shells interpolating
variables into strings, and sharing many of the same escape sequences in
quoted string constants, that's an easy place for bugs to sneak in.

Also, the return value from system() isn't just the return value of the
called command; it's that, plus some other stuff. You need to jump through
a few hoops to get the actual exit status, as shown in "perldoc -f system":

You can check all the failure possibilities by inspecting $? like this:

if ($? == -1) {
print "failed to execute: $!\n";
}
elsif ($? & 127) {
printf "child died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
}
else {
printf "child exited with value %d\n", $? >> 8;
}

Once you get the real exit code from the tool you're calling, then you can
find the meaning of that code (and the accompanying "Can't init" message)
in the tool's docs.

sherm--

--
WV News, Blogging, and Discussion: http://wv-www.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
From: lbo_user on
OK, thanks for the help so far. Here's some more detail and the code
itself.

I'm running a script that transcodes FLAC to MP3 hence it calls both
the flac and lame executables with the relevant options and file
paths. The script tries to create a mirrored directory structure of
the source flac tree. You can get the code here: http://robinbowes.com/projects/flac2mp3

I've been in touch with the author but he doesn't have an OS X machine
to test on. It seems to work fine on Windows and possibly Linux. If
you look at the script, the parts to search for are $convert_command
which is a concatenation of tools, arguments and paths, and the
variable $tmpfilename which is the temp destination filename that it
fails to write.

Having added Sherman's code to get the actual error, running the
script returns the following:


[macbaddy:~] sjalloq% flac2mp3.pl /Volumes/FreeNAS/MEDIA/FLAC /Volumes/
FreeNAS/MEDIA/MP3_new
Using flac from: /usr/local/bin/flac
Using lame from: /usr/local/bin/lame
Processing directory: /Volumes/FreeNAS/MEDIA/FLAC
1546 flac files found. Sorting...
Sort complete.

Here is the source file info:
src_base: 01-Young Black Male
src_dir: ./
src_ext: .flac
Transcoding "2Pac/2Pacalypse Now/01-Young Black Male.flac"

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.

Can't init outfile '/Volumes/FreeNAS/MEDIA/MP3_new/2Pac/2Pacalypse Now/
OwbFwjqwWP.tmp'
child exited with value 255
"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" failed with exit
code 65280
[macbaddy:~] sjalloq%
From: J. Gleixner on
052lbo_user wrote:

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

Hu.. permission problem? Does the file exist?

> "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?

Run the flac command, redirect output to a file, maybe there's
something in there? If that works, then redirect that file
to the lame command. If there's a verbose option to those,
then try that.

It's not a perl problem, so focus on something else.


> failed with exit code 65280