Python webbrowser with root

hi

experienced an issue with python webbrowser fonction

in normal user i can open an url with:

jluce@hp16:~/Bureau> python
Python 2.7.3 (default, Apr 14 2012, 08:58:41) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import webbrowser
>>> new = 2
>>> url = "http://docs.python.org/library/webbrowser.html"
>>> webbrowser.open(url,new=new)
True
>>> 

it open firefox onthe good url

but in root

i did the same but the browser did’nt load and the url was open in the terminale

any ideas ???

regards

jluce

While you of course may do as you think fit, I would like to mention to all others that IMHO it is not a good idea (to say at least) to go to the World Wide Web using root.

II know this is not a solution for the problem. Sorry about that.

I do not quite understand what your situation is. Is that terminal command (python) given from a terminal emulator running in a user GUI session? Or is the command given from a real console? Or is it given from a terminal emulator running in a root GUI session (which would of course be very bad berhaviour)?

And it seems that you think it should start Firefox. This means that some GUI session is also required. Now when you start this from a terminal as user in that user’s GUI, I do not see a problem for FF to be started in that same GUI session. (And you report that that works if I am correct).

But when you start this as a different user (root or other) inside or outside of a user’s GUI session, that will not work without further action. Because other users are not allowed to open windows in a GUI session not of their own (sounds logical, doesn’t it?)

And please, please, please, start every question/ptroblem description with the basic information about what you use. The openSUSE version is missing. Same for the DE you use in that GUI session.

hi

thanks for answer !!!

no problem but it is the same thing when i do a

su - user -c 'python -mwebbrowser "url"'

it not opened url in firefox or an other browser, it opened it in the terminale where i run the command line !!!

how to open firefox in this usecase ??

regards

jluce

i have a gui to configure ufw (a firewall) i launch it with xdg-su so i am in root (i think…) so in the code i can see the command is like i said in my last post

opensuse 12.3
KDE 4.11 RC1

i will update my profile

regards

jluce

On 07/22/2013 03:26 PM, jluce2 wrote:
> su - user -c ‘python -mwebbrowser “url”’

is that (with “user”) the actual command you use?


dd

hi thanks for answer

yes

i can see thin in the python code:

cmd = "su -l " + user + " -c 'python -mwebbrowser " + url + "'"

regards

jluce

First check from that other users’ session if the DISPLAY variable is set (and what it’s value is):

echo $DISPLAY

When that is not correct the client does not know which X-server to use and allso not which display on thet server.

Then the owner of that GUI session must allow acces. Check with

xhost

or allow everybody:

xhost +

BTW IMHO you better test this with a simple X program like xclock.

On Mon, 22 Jul 2013 11:46:01 +0000, jluce2 wrote:

> i did the same but the browser did’nt load and the url was open in the
> terminale

What was the specific output you did get from those commands run as
root?

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C