473,503 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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:

<?php

putenv("VIEWER_HOME=/path/to/viewer_home");

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

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

?>

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?

TIA,
Hemanth

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.

Jul 17 '05 #1
3 2416
Hemanth <he*****************@gmail.com> wrote:
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?
You can...
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.


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.

Solution:
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:
putenv('DISPLAY=localhost:45');

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

Jul 17 '05 #2
Daniel,

Sorry for a late reply. Could you please elaborate on your first
solution.
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

Jul 17 '05 #3
BTW, the viewer program I'm running is K2 Quickview.

- Hemanth

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2650
by: Dan V. | last post by:
Situation: I have to connect with my Windows 2000 server using VS.NET 2003 and C# and connect to a remote Linux server at another company's office and query their XML file. Their file may be...
14
8984
by: jj | last post by:
Is it possible to call a remote php script from within Access? I'm thinking something like: DoCMD... http://www.domain.com/scripts/dataquery.php DoCmd.OpenQuery "update_data", acNormal, acEdit...
5
5658
by: mayamorning123 | last post by:
A comparison among six VSS remote tools including SourceOffSite , SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET To view the full article, please visit...
0
3271
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed...
6
1807
by: Dan V. | last post by:
Is there a way to query a remote xml file periodically by not using web services? For Windows and Unix platforms. Is there a cheap software product that I can install on each client and my Windows...
14
2513
by: Brent Burkart | last post by:
I am trying to capture the Windows Authenticated username, but I want to be able to capture the login name that exists in IIS, not Windows. In order to enter my company's intranet through the...
6
2244
by: doublemaster007 | last post by:
Is there any debugger in which i can remotly debug Linux exe in windows system...i mean debugger should be in windows and connect to Linux machin in which the executable is running..! is there...
3
9039
by: Scott | last post by:
I have a requirement to control a firefox web browser from an external python program. The python program running under linux from a command shell needs to first find all open firefox web browser...
0
1512
by: bruce | last post by:
hi mike.... you might look at/into selenium, or firewatir.... check the spellings! -peace -----Original Message-----
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.