I just need the cgi server side display an html file with firefox on its own
monitor(using os.system call in python),and i do not use mod_python.All like,I
click
on client,and then server show the html file on its screen. Here is the source code.
#!/usr/bin/env python
import cgi
import os
print 'Content-Type: text/html\n\n'
os.system('firefox --display=:0.0 test.html')
|
But it cannot work for me,the cgi script stopped at os.system statement,and apache2 log file shows:
No protocol specified No protocol specified Error: cannot open display: :0.0The above message mean that the apache2 default user
www-data cannot connect to the X session used by your login username(like
djstava) and also cannot open the $DISPLAY.
First I think the simplest method to solve it is changing the apache2 default user
www-data to the system login username
djstava.
sudo vi /etc/apache2/envvars
export APACHE_RUN_USER=
djstava export APACHE_RUN_GROUP=
djstavaRestart the apache2,it works,firefox show the html file clearly.
But when I reboot the system,the /var/log/apach2/error.log also write down the error message unfortunately.
And second,I change the apache2 default user back to
www-data,all i have to do is let the
www-data gaining the accesss to the X display owned by user
djstava.
sudo xhost +local:
www-dataNow everything works well.
djstava
阅读(2197) | 评论(0) | 转发(0) |