Capturing a display on remote (linux) server from (windows) web browser

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hello there,

I've a utility that runs on a linux machine. Basically, it opens
a window, draws a figure and captures the image (screen) and stores
it as a jpeg file.  The utility requires a window to be open
(or displayed) inorder to save the image. Also, this utility is
in the form of an executable, so I can't possibly alter it.

I want to run this utility from a windows web browser and display
the saved jpeg file. I pass some command line parameters to change
the figure it draws. The php code I use is as below:



//putenv("DISPLAY servername:45");

$prgfile="viewer -m save.mac";
exec($prgfile, $output, $rc);
foreach($output as $row)    echo "<br>$row";
echo "<br>";


I connect to the linux server from my windows desktop using RealVNC
and the php script works when I run it from the server shell
prompt (using "php <scriptname>"). It opens a display, captures the
image and closes the display. But when I run the script from windows
web browser I get an error (in the apache "error_log" file).

"Error: Can't open display"

Is there a way I can make this work?


P.S: I'm not sure if my question is entirely relevant to this group
but any pointers to the right group will be helpful.

Re: Capturing a display on remote (linux) server from (windows) web browser

Quoted text here. Click to load it

You can...

A linux group offcourse, related to X: comp.os.linux.x (or simply misc)
might be better. If you don;t understand below take it there :)

The difference is that when you run the script from commandline in vnc,
it's running as you and it has an readily available display to write to.

Apache is running under an other user and knows not of any display to
write to.

Q&D: give apache access to your vnc session (which from then on will
need to be running always on a known port), with 'xhost localhost' and
set the DISPLAY variable in your script to that display:

This will give _ANY_ user on localhost access to your display, enabling
them to read every key you type and your entire screen.

Less Q&D: run an vnc session as the apache user, you can then leave out
the xhost part.

BTW what program are you running (just curious)?

Re: Capturing a display on remote (linux) server from (windows) web browser


Sorry for a late reply. Could you please elaborate on your first
Normally, I run a startup script to open a vnc session. I tried to do
the same from the web browser (trying to start a vnc session using
apache user on port 99). The startup script I used is as follows:

Xvnc -geometry 800x600 -depth 24 :99 &
sleep 4
setenv DISPLAY "$HOST":99
sleep 4
/usr/bin/startkde &

The script works when I run it using myuserid. But I get this error
message (in apache error_log)  when run from webbrowser.

Fatal server error:
Cannot establish any listening sockets - Make sure an X server isn't
already running
sh: setenv: command not found
Cannot create temp file //KDE.startkde.3JrTHi
/usr/bin/startkde: $testfile_home: ambiguous redirect
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running

Could you pls throw some light on it.

- Hemanth

Re: Capturing a display on remote (linux) server from (windows) web browser

BTW, the viewer program I'm running is K2 Quickview.

- Hemanth

Site Timeline