Failed with exit code 65280.

Failed with exit code 65280.

am 26.11.2007 16:54:19 von lbo_user

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.

Re: Failed with exit code 65280.

am 26.11.2007 17:48:43 von xhoster

lbo_user 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.

Re: Failed with exit code 65280.

am 26.11.2007 18:44:29 von Sherm Pendley

lbo_user 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

Re: Failed with exit code 65280.

am 27.11.2007 21:41:04 von lbo_user

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%

Re: Failed with exit code 65280.

am 27.11.2007 22:06:14 von glex_no-spam

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

Re: Failed with exit code 65280.

am 27.11.2007 22:11:43 von lbo_user

On 27 Nov, 21:06, "J. Gleixner"
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
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.

Re: Failed with exit code 65280.

am 27.11.2007 22:50:53 von Sherm Pendley

lbo_user 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

Re: Failed with exit code 65280.

am 27.11.2007 23:04:58 von glex_no-spam

lbo_user wrote:
> On 27 Nov, 21:06, "J. Gleixner"
> 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.

Re: Failed with exit code 65280.

am 28.11.2007 00:13:49 von lbo_user

> 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.

Re: Failed with exit code 65280.

am 28.11.2007 01:10:20 von lbo_user

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?

Re: Failed with exit code 65280.

am 28.11.2007 01:38:32 von lbo_user

Right, I must apologise, it's late and I'm not thinking straight.
Ignore my last post as I have found the real reason this time. I'm
using a FreeNAS server which doesn't seem to like me reading and
writing to it at the same time. If I run the original script and
stream from the FreeNAS to my local machine everything is fine. If I
stream from AND try to write to the FreeNAS it barfs.

Definitely not a Perl problem, but thanks for all the help.

Re: Failed with exit code 65280.

am 28.11.2007 03:31:00 von krahnj

lbo_user wrote:
>
> 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?

When you use a piped stream perl's system() invokes a shell to (parse
and) run the command(s). Without the pipe the command(s) are run
without a shell.



John
--
use Perl;
program
fulfillment

Re: Failed with exit code 65280.

am 28.11.2007 03:53:26 von Ben Morrow

Quoth "John W. Krahn" :
> lbo_user wrote:
> >
> > 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?
>
> When you use a piped stream perl's system() invokes a shell to (parse
> and) run the command(s). Without the pipe the command(s) are run
> without a shell.

" counts as a shell metacharacter (perl doesn't want to try to
understand your shell's quoting rules) and will still cause perl to use
the shell. Since avoiding the shell is usually a good thing, this
example would be better written

system @$_ for
[$flaccmd, @flacargs, $quotedsrc, -o => $flacoutname],
[$lamecmd, @lameargs, $flacoutname, $tmpfilename];

having first made sure that there is no quoting of the parameters:
$quotedsrc, for instance, sounds like it's been quoted (:)), and mustn't
be.

Ben