I have one linux box (box1) which provides the X server.
On another linux box (box2), I have my perl scripts to debug.
On box1, I can do "ssh -X box2" and the DISPLAY variable is set to "localhost:10.0" and if I run my perl script manually (perl -d:ptkdb dbs.pl), the ptkdb window comes up on box1. I can click RUN and all goes well.
The perl code for dbs.pl is
#!/usr/bin/perl print "Hello World\n";
Now, when I want to run a CGI program, things don't go so well: The code is just as simple for dbs.cgi:
#!/usr/bin/perl -d:ptkdb use CGI (':standard'); print header; print start_html; print "Hello"; print end_html;
The problem now is that I get the message:
couldn't connect to display ":0" at /perl_modules/lib/site_perl/5.12.0/s390x-linux/Tk/MainWindow.pm line 55.

Doing ssh -X sets the DISPLAY variable for me, but the web server does not know what to do. I tried adding a line like
$ENV{DISPLAY} = "localhost:0.0";
But that didn't work. I have also used xhost to try and set things up, but to no avail. If I don't invoke with -d:ptkdb, then the cgi script properly displays "Hello" on the browser screen.
So, what other steps might I try, so that my cgi scripts can connect to the X server display? I guess the problem is that apache doesn't know how to redirect the X11 output to the host running my browser.

In reply to ptkdb cannot connect to DISPLAY by ciumes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.