Allowing a CGI to launch an application

Discussion in 'Perl Misc' started by elentirmo@gmail.com, Dec 15, 2005.

  1. Guest

    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
     
    , Dec 15, 2005
    #1
    1. Advertising

  2. Anno Siegel Guest

    <> wrote in comp.lang.perl.misc:
    > 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
    --
    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
     
    Anno Siegel, Dec 15, 2005
    #2
    1. Advertising

  3. Guest

    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?
     
    , Dec 15, 2005
    #3
  4. Anno Siegel Guest

    <> wrote in comp.lang.perl.misc:
    > 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
    --
    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
     
    Anno Siegel, Dec 15, 2005
    #4
  5. wrote:
    > 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
     
    Jürgen Exner, Dec 15, 2005
    #5
  6. Lucas Young Guest

    On 2005-12-15 23:29:34 +1300, -berlin.de (Anno
    Siegel) said:

    > <> wrote in comp.lang.perl.misc:
    >> 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


    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...
     
    Lucas Young, Dec 15, 2005
    #6
  7. Lucas Young Guest

    On 2005-12-15 23:56:54 +1300, "Jürgen Exner" <> said:

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


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

    <> wrote in comp.lang.perl.misc:
    > 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

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


    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...
     
    Lucas Young, Dec 15, 2005
    #7
  8. Dr.Ruud Guest

    Lucas Young:

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


    *PLONK*

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, Dec 15, 2005
    #8
  9. Matt Garrish Guest

    "Lucas Young" <> wrote in message
    news:...
    > On 2005-12-15 23:29:34 +1300, -berlin.de (Anno
    > Siegel) said:
    >
    >> <> wrote in comp.lang.perl.misc:
    >>> 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.
    >>

    >
    > 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
     
    Matt Garrish, Dec 15, 2005
    #9
  10. "Matt Garrish" <> writes:
    > "Lucas Young" <> wrote in message
    > news:...
    >> 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.


    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
     
    Eric Schwartz, Dec 15, 2005
    #10
  11. Matt Garrish Guest

    "Eric Schwartz" <> wrote in message
    news:...
    > "Matt Garrish" <> writes:
    >> "Lucas Young" <> wrote in message
    >> news:...
    >>> 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.

    >
    > 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
     
    Matt Garrish, Dec 15, 2005
    #11
  12. Lucas Young Guest

    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

    On 2005-12-16 07:44:00 +1300, Jim Gibson <> said:

    > In article <>,
    > <""> wrote:
    >
    >> 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

    >
    > CGI programs run on the server. It sounds like you would like to launch
    > a program on your local machine, the client. The "current window" is
    > probably a browser window. Getting a browser to do something on your
    > local machine has nothing to do with Perl. Your browser will need some
    > sort of plug-in installed to allow it to handle a certain type of
    > downloaded material.
    >
    > Of course, I may have misunderstood your problem entirely.
    >
    > Posted Via Usenet.com Premium Usenet Newsgroup Services
    > ----------------------------------------------------------
    > ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
    > ----------------------------------------------------------
    > http://www.usenet.com
     
    Lucas Young, Dec 15, 2005
    #12
  13. l v Guest

    wrote:
    > 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
     
    l v, Dec 16, 2005
    #13
  14. Matt Garrish <> wrote:
    > "Eric Schwartz" <> wrote in message
    > news:...


    >> Matt may have come across a bit harsh,

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


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Dec 16, 2005
    #14
  15. Lucas Young <> wrote:
    > On 2005-12-15 23:56:54 +1300, "Jürgen Exner" <> said:
    >> wrote:
    >>> 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.

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


    >> Of course this has nothing to do with Perl.
    >>
    >> jue



    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.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Dec 16, 2005
    #15
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JDS
    Replies:
    4
    Views:
    8,288
    ForestHonerkamp
    Nov 11, 2008
  2. JB
    Replies:
    7
    Views:
    4,200
    Mark Northup
    Oct 6, 2010
  3. JDS
    Replies:
    3
    Views:
    198
    gnari
    May 24, 2004
  4. erik
    Replies:
    19
    Views:
    473
    Gunnar Hjalmarsson
    Jun 27, 2005
  5. alpha_beta_release

    Allowing threading with CGI

    alpha_beta_release, Aug 28, 2006, in forum: Perl Misc
    Replies:
    10
    Views:
    331
    alpha_beta_release
    Sep 5, 2006
Loading...

Share This Page