Permissions

C

CaptnDenny

I'm on a home made juke box project. If I understand this correctly,
cgi scripts written for perl execute under the user "nobody". I can
make a script to execute mpg123 such as

#!/usr/bin/perl
system ("mpg234 musicfile.mp3");

and when run from the command line (after suing into the user "nobody")
all is well and it works. But if I try it from an html link to
/cgi-bin/music.pl it gives me an error.

I've tried to make a script that would pipe the user info using "whoami
textfile.txt but it apparently suffers from my same ignorance.(but works from the comandline)

Any suggestions are welcome
Thanks
Dennis
 
J

Jimbo

CaptnDenny said:
I'm on a home made juke box project. If I understand this correctly,
cgi scripts written for perl execute under the user "nobody". I can
make a script to execute mpg123 such as

#!/usr/bin/perl
system ("mpg234 musicfile.mp3");

and when run from the command line (after suing into the user "nobody")
all is well and it works. But if I try it from an html link to
/cgi-bin/music.pl it gives me an error.
1. Share with us the specific error message.
2. Rename music.pl to music.cgi and try again.
 
C

CaptnDenny

I tried renaming it.
This is the same error that the .pl extension gives me

Server error!

The server encountered an internal error and was unable to complete
your request.

Error message:
Premature end of script headers: music.cgi

If you think this is a server error, please contact the webmaster.
Error 500
192.168.4.28
Wed Feb 1 22:32:56 2006
Apache/2.0.50 (Linux/SUSE)
 
J

John Bokma

Error message:
Premature end of script headers: music.cgi

Yup, what are you returning?

print "Content-Type: text/plain\n\n"; # untested

might fix it. (The server expects your script to return at least a header
telling what your script *is* returning (type)).
 
T

Tintin

CaptnDenny said:
I'm on a home made juke box project. If I understand this correctly,
cgi scripts written for perl execute under the user "nobody". I can
make a script to execute mpg123 such as

#!/usr/bin/perl
system ("mpg234 musicfile.mp3");

and when run from the command line (after suing into the user "nobody")
all is well and it works. But if I try it from an html link to
/cgi-bin/music.pl it gives me an error.

And you didn't think that the error could have been important?

I don't see the point in what you are doing. If the jukebox is just for
your server, then why bother with invoking it via a CGI script? I hope you
don't think that users browsing your website will be able to hear the mp3
file (you will, they won't).
 
C

CaptnDenny

Thanks for the idea. It stops the error but still doesn't work.
What may be another option for "Type"?
I googling.......
 
J

Jürgen Exner

CaptnDenny said:
I tried renaming it.
This is the same error that the .pl extension gives me [...]
Error 500

Did you check and follow the steps in the FAQ?
See "perldoc -q 500"

jue
 
C

CaptnDenny

I'm not getting an error now since I added the header.....it just does
nothing from the html link. It runs from the command line.
I tried perl -c music.pl
and got syntax ok
still reading thru the troubleshooting guide but nothing is standing
out at me.
(I'm not a scripter)
 
J

Jürgen Exner

CaptnDenny said:
I'm not getting an error now since I added the header.....it just does
nothing from the html link. It runs from the command line.

In this case the probability that you have a Perl problem are very(!!) low.
You should look into other areas first.
I tried perl -c music.pl
and got syntax ok

It wouldn't "run from the command line" if it had a syntax error, would it?

jue
 
J

Jürgen Exner

CaptnDenny said:
I'm on a home made juke box project. If I understand this correctly,
cgi scripts written for perl execute under the user "nobody".

Maybe, maybe not. Depends on how your web server and the script are
configured.
I can
make a script to execute mpg123 such as

#!/usr/bin/perl
system ("mpg234 musicfile.mp3");

and when run from the command line (after suing into the user
"nobody") all is well and it works.

Now, if only we knew what you mean by "all is well and it works".
Do you mean "it plays the file on the local machine"?
But if I try it from an html link
to /cgi-bin/music.pl it gives me an error.

Ok, further down in the thread you apparently fixed this and are not getting
the unknown error any longer.
But now your script "still doesn't work". Unfortunately you still didn't
tell us what you expect the script to do versus what the actual behaviour of
your script you are observing.

If you don't tell us then we can only guess and our guesses may be very
wrong.
Therefore *wild*guess*warning*:

Are you by any chance trying to run the script on the web server using that
system() statement above and expecting the music to play on the client?

jue
 
C

CaptnDenny

The server is tied to the home sound system. If you run the script
using perl, the output is sent to the amp.....it plays ok.
If I run it from the command line "./music.pl" it plays ok.
All I want to do is have a web page with the links to various playlists
on it, that when clicked on from any location in the house
it will play on the home sound system.
All I get is a blank html screen when clicked on.

No....I'm not expecting it on the client
 
J

J. Gleixner

CaptnDenny said:
The server is tied to the home sound system. If you run the script
using perl, the output is sent to the amp.....it plays ok.
If I run it from the command line "./music.pl" it plays ok.
All I want to do is have a web page with the links to various playlists
on it, that when clicked on from any location in the house
it will play on the home sound system.
All I get is a blank html screen when clicked on.

No....I'm not expecting it on the client

Include some content when you reply.

Possibly 'mpg234' requires some environment variables that are set for
your login, but not for 'nobody', or the login your Web server is
running under?

Try
* 'su - nobody', then try running the script from the command line. Any
errors?

* Redirect output/errors to some file and check the file after running
it via Web server. Suggest you use full path to mpg234. Use any verbose
or debug options to mpg234, to help see what's happening.

#!/usr/bin/perl
use CGI qw( :header );
$|++;
print header, "Starting mpg234 musicfile.mp3..";

system( "/full/path/to/mpg234 musicfile.mp3 2>&1 > /tmp/mpg234.output &"
) == 0 or die "mpg234 failed: $?";

print "mpg234 successfully started.";
 
C

CaptnDenny

Its definitly starting to smell like mpg123 problems. Heres the output
from your script to the browser:

Starting mpg123 music.mp3..mpg123 successfully started.High Performance
MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3. Version 0.59s-mh4
(2000/Oct/27). Written and copyrights by Michael Hipp. Uses code from
various people. See 'README' for more! THIS SOFTWARE COMES WITH
ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK! Can't open /dev/dsp!
 
J

J. Gleixner

CaptnDenny said:
Its definitly starting to smell like mpg123 problems. Heres the output
from your script to the browser:

Whose script? Again, please include relevant parts of the message, when
replying!
Starting mpg123 music.mp3..mpg123 successfully started.High Performance
MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3. Version 0.59s-mh4
(2000/Oct/27). Written and copyrights by Michael Hipp. Uses code from
various people. See 'README' for more! THIS SOFTWARE COMES WITH
ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK! Can't open /dev/dsp!

Check the permissions for /dev/dsp. Not sure why it wouldn't be
writable by 'other', but possibly doing a 'chmod' on that special file
might resolve it.

I think it's safe to say this is no longer a perl question/issue.
 
C

CaptnDenny

Hello all,
Thanks for the help everybody. It wouldn't have happened with out your
help.
I did a chmod 622 on /dev/dsp and /dev/audio and SHABANG it worked.
Any idea how I would do this same thing and have the browser return to
where it was
or maybe never leave the original link location when the original link
was clicked on?
(just lazy and saving clicks on the mouse)
Thanks everybody for bearing with me on this one
Dennis
 
I

Ian Wilson

CaptnDenny said:
Hello all,
Thanks for the help everybody. It wouldn't have happened with out your
help.

You are using google groups to post to newsgroups, please read
http://groups.google.com/googlegroups/posting_style.html#summarize
I did a chmod 622 on /dev/dsp and /dev/audio and SHABANG it worked.
Any idea how I would do this same thing and have the browser return to
where it was

I'd emit either an HTTP redirect in the headers or a META HTTP-Redirect
in the HTML. This is not a Perl question, so it would be best to
follow-up in a HTTP or HTML newsgroup.
or maybe never leave the original link location when the original link
was clicked on?

You can use Javascript to control what happens when a link is clicked.
This is not a Perl question, follow up in a Javascript newsgroup.

You could try JWZ's "Gronk" maybe? Google will find it for you.
 

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,139
Messages
2,570,805
Members
47,356
Latest member
Tommyhotly

Latest Threads

Top