Failed with exit code 65280.

L

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

xhoster

lbo_user said:
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.
 
L

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%
 
J

J. Gleixner

052lbo_user said:
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.
 
L

lbo_user

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

J. Gleixner

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


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

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

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

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

John W. Krahn

lbo_user said:
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
 
B

Ben Morrow

Quoth "John W. Krahn said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,206
Messages
2,571,069
Members
47,678
Latest member
Aniruddha Das

Latest Threads

Top