Allowing a CGI to launch an application


E

elentirmo

Hi
I'm using Ubuntu Linux and need a Perl CGI application to launch an
application (totem). This will happen at the machine (not remotely) -
it's for a private movie player I'm writing in PHP & Perl.
When I try to execute `/usr/bin/totem` I get the following error in
the Apache log:
(totem:9597): Gtk-WARNING **: cannot open display:
Which I think is due to the display environment variable settings for
the Apache www-data user... how do I configure the box to let www-data
launch an application in the current window?
many thanks in advance

Lucas
 
Ad

Advertisements

A

Anno Siegel

Hi
I'm using Ubuntu Linux and need a Perl CGI application to launch an
application (totem). This will happen at the machine (not remotely) -
it's for a private movie player I'm writing in PHP & Perl.
When I try to execute `/usr/bin/totem` I get the following error in

Don't call programs through backticks unless you need the output.
the Apache log:
(totem:9597): Gtk-WARNING **: cannot open display:
Which I think is due to the display environment variable settings for
the Apache www-data user... how do I configure the box to let www-data
launch an application in the current window?
many thanks in advance

Why would apache set the DISPLAY variable? It's not an X application.
Anyway, unset it. This has nothing to do with Perl.

Anno
 
E

elentirmo

Sorry maybe I worded that wrongly... but the www-data user that Apache
runs as needs to be able to open an application, how do i set that up?
 
A

Anno Siegel

Sorry maybe I worded that wrongly... but the www-data user that Apache
runs as needs to be able to open an application, how do i set that up?

Exactly the same way you run an external program from any Perl script.
See perldoc -f system and read also the docs that one points to.

Anno
 
J

Jürgen Exner

Sorry maybe I worded that wrongly...

You worded _what_ wrongly? If you are replying to an article please quote
appropriate -as has been customary for two decades- such that people have a
chance to know what your are talking about.
but the www-data user that Apache
runs as needs to be able to open an application, how do i set that up?

Well, you give the user www-data execute permission to that application.
Just like with any other program.
Of course this has nothing to do with Perl.

jue
 
L

Lucas Young

Exactly the same way you run an external program from any Perl script.
See perldoc -f system and read also the docs that one points to.

Anno

You dont seem to understand
Running a CGI from a browser is not the same as running a perl script
from the comand line. On the command line it runs as you, from a
browser it runs as the www-data Apache user. Calling
system("/usr/bin/totem") works ok from the command line, from a CGI it
generates this error in the Apache logs:
(totem:9597): Gtk-WARNING **: cannot open display:
As far as I can work out it's something to do with the www-data user
not having access to the display device. I thought someone who used CGI
a lot might know how to get this working...
 
Ad

Advertisements

L

Lucas Young

You worded _what_ wrongly? If you are replying to an article please
quote appropriate -as has been customary for two decades- such that
people have a chance to know what your are talking about.

Well, all you had to do was look at the previous message in the thread:

Hi
I'm using Ubuntu Linux and need a Perl CGI application to launch an
application (totem). This will happen at the machine (not remotely) -
it's for a private movie player I'm writing in PHP & Perl.
When I try to execute `/usr/bin/totem` I get the following error in

Don't call programs through backticks unless you need the output.
the Apache log:
(totem:9597): Gtk-WARNING **: cannot open display:
Which I think is due to the display environment variable settings for
the Apache www-data user... how do I configure the box to let www-data
launch an application in the current window?
many thanks in advance

Why would apache set the DISPLAY variable? It's not an X application.
Anyway, unset it. This has nothing to do with Perl.

Anno
Well, you give the user www-data execute permission to that
application. Just like with any other program.
Of course this has nothing to do with Perl.

jue

Anyway, as I said to Anno:
Running a CGI from a browser is not the same as running a perl script
from the comand line. On the command line it runs as you, from a
browser it runs as the www-data Apache user. Calling
system("/usr/bin/totem") works ok from the command line, from a CGI it
generates this error in the Apache logs:
(totem:9597): Gtk-WARNING **: cannot open display:
As far as I can work out it's something to do with the www-data user
not having access to the display device. I didnt expect people to get
nasty about the question, I just thought someone who used CGI a lot
might know how to get this working...
 
M

Matt Garrish

Lucas Young said:
You dont seem to understand

Seems you're the one with the lack of understanding here.
Running a CGI from a browser is not the same as running a perl script
from the comand line.

That's hardly news to anyone.
On the command line it runs as you, from a browser it runs as the www-data
Apache user.

So you don't have a Perl problem; you have a problem configuring your
server. It's not surprising that your cgi scripts cannot execute anything it
wants on your server. How you loosen up your machine isn't of interest to
anyone here, though.

Matt
 
E

Eric Schwartz

Matt Garrish said:
So you don't have a Perl problem; you have a problem configuring your
server. It's not surprising that your cgi scripts cannot execute anything it
wants on your server. How you loosen up your machine isn't of interest to
anyone here, though.

Lucas,

Matt may have come across a bit harsh, but one thing that is crucial
to solving a problem is being able to partition it properly. In your
case, you have four components:

1) A user making some sort of HTTP request of
2) A webserver, receiving those requests and passing them on to
3) A CGI script, which wants to run a program that connects to
4) An X server

Matt correctly recognized the problem is with the webserver
configuration. The point here is not that you're stupid, but simply
that your problem would be the same problem if your CGI was written in
Perl, C, Ruby, Python, or Scheme. So asking about it here is
pointless-- you're better off asking questions that are generic to
webservers or CGI in newsgroups dealing with webservers or CGI.

Try:

comp.infosystems.www.authoring.cgi - for CGI questions, and
comp.infosystems.www.servers.unix - for Unix webserver configuration
questions. (Similar groups exist
for other OS families.)

If you can learn to partition your problem well, then you'll be able
to ask better questions of the right people, and that will help you
get the best answers quicker.

-=Eric
 
M

Matt Garrish

Eric Schwartz said:
Lucas,

Matt may have come across a bit harsh,

Probably, but I didn't like the tone. Newbies talking down to the people
trying to help them gets under my skin...

Matt
 
Ad

Advertisements

L

Lucas Young

Thanks Jim

I've made some progress -
I've got it working now by using xhost + in my .bashrc and using the
--display=localhost:0 option when calling totem

Thanks everyone for your help :)

cheers

Lucas
 
L

l v

Hi
I'm using Ubuntu Linux and need a Perl CGI application to launch an
application (totem). This will happen at the machine (not remotely) -
it's for a private movie player I'm writing in PHP & Perl.
When I try to execute `/usr/bin/totem` I get the following error in
the Apache log:
(totem:9597): Gtk-WARNING **: cannot open display:
Which I think is due to the display environment variable settings for
the Apache www-data user... how do I configure the box to let www-data
launch an application in the current window?
many thanks in advance

Lucas

Your script needs to set the DISPLAY environment variable to the ip
address of the client which sent the HTTP request. And as others have
stated, you should not be using backtics for this.

Len
 
T

Tad McClellan

Matt Garrish said:
Probably, but I didn't like the tone.


Me either.

Newbies talking down to the people
trying to help them gets under my skin...


I'll (usually) let it pass once.

A second occurance is the fast-track to perpetual invisibility though.
 
Ad

Advertisements

T

Tad McClellan

Lucas Young said:
Well, all you had to do was look at the previous message in the thread:


You have now qualified for a ride on the fast-track!

Looks like Matt's attitude-detector is in a fine state of tune...

So long!

This has nothing to do with Perl.

Anno


That is true.

(so it is off-topic in a Perl newsgroup)



There is that pesky true stuff again!

Anyway, as I said to Anno:


Repeating the same thing over and over does not convert it
from being wrong to being right.

I didnt expect people to get
nasty about the question,


That can happen with off-topic questions.

The corollary then is to not ask off-topic questions, or to at
least let the thread die once you discover that it is off-topic.

I just thought someone who used CGI a lot
might know how to get this working...


Then you should be asking in a newsgroup where folks who
use CGI a lot hang out:

comp.infosystems.www.authoring.cgi

This is the Perl newsgroup, not the CGI newsgroup.
 

Top