LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-28-2011, 10:39 AM   #1
laredotornado
Member
 
Registered: Apr 2011
Posts: 71

Rep: Reputation: 0
How do I spawn browser windows from a service?


Hi,

I'm using Ubuntu 10.0.4. I'm running a background process on system startup (Selenium) that needs to launch browsers (e.g. Firefox, Google Chrome). What settings do I need to enable in order to do this? Currently, even if I SSH in as a user, I'm not able to launch a browser and get this error ...

Code:
selenium@selenium-chi:~$ /usr/bin/google-chrome 
No protocol specified

(chromium-browser:2156): Gtk-WARNING **: cannot open display: :0.0
Anyway, thanks for any insights you can provide, - Dave
 
Old 04-28-2011, 12:59 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,978

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
This is the problem. "cannot open display: :0.0"

You have to have some place for a gui to go.

May help you with this.
http://www.thegeekstuff.com/2009/07/...ystem-startup/
 
Old 04-28-2011, 01:23 PM   #3
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
If you ssh in with X forwarding enabled, then you'll be to launch a browser or whatever GUI app you want to launch. The icon on your post indicates you were using a Mac at the time and the good news is that Mac OS X comes with an X windows implementation. So to run GUI applications over ssh you can just do

Code:
$ ssh -X user@host
 
Old 04-28-2011, 01:25 PM   #4
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
Oh hang on, is X11.app installed by default in Mac OS X these days? I can't remember. Look in Applications > Utilities and see if X11.app is there. If it's not, dig out the discs which came with your Mac or your Mac OS X installation disk and you should find X11.app on there somewhere. Unless you're using a really old version of Mac OS X, X11.app should launch automatically when you establish an ssh connection with X forwarding enabled.
 
Old 04-29-2011, 09:07 AM   #5
laredotornado
Member
 
Registered: Apr 2011
Posts: 71

Original Poster
Rep: Reputation: 0
A couple of clarifications. I'm posting from a Mac, but I'm using Ubuntu 10.0.4 installed on Intel x64 hardware.

The X-forwarding is valuable info, but ultimately, I want to be able to spawn browser windows from a service that I run on system startup. So, I'm not SSH'ing and launching the service, it is being run at system startup, courtesy of my script in /etc/init.d.

Given this, how do I give the service the ability to spawn browser windows? Thanks, - Dave
 
Old 04-29-2011, 09:23 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
How about

Code:
/usr/bin/google-chrome -display :0
 
Old 04-29-2011, 12:05 PM   #7
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,978

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
Permissions on script? Who is running the script?
 
Old 04-29-2011, 12:12 PM   #8
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
Are you trying to launch a web browser during boot, before a user has logged in?

You can do it by using a virtual X session which xvfb (if it's not installed it'll be in the repos).
Code:
$ xvfb :99 &
$ DISPLAY=:99 firefox
 
Old 04-29-2011, 12:34 PM   #9
laredotornado
Member
 
Registered: Apr 2011
Posts: 71

Original Poster
Rep: Reputation: 0
Hi,

For the permissions question, owner is root, but process is being run by a user (selenium) I created

Code:
selenium@selenium-chi:~$ ls -al /etc/init.d/selenium-server 
-rwxr-xr-x 1 root root 1142 2011-04-28 10:33 /etc/init.d/selenium-server
I spawn the process by running ...
Code:
su selenium -c 'java -jar /opt/selenium/selenium-server-standalone-2.0b3.jar -userExtensions /opt/selenium/user-extensions.js &>/dev/null &'
Arizonagroovejet, Selenium will attempt to launch a web browser before a user has logged in but after the boot up process has completed. I tried your suggestion, but was unable to launch xvfb ...

Code:
selenium@selenium-chi:~$ xvfb :99 &
[1] 1623
selenium@selenium-chi:~$ No command 'xvfb' found, did you mean:
 Command 'qvfb' from package 'qt4-dev-tools' (main)
 Command 'qvfb' from package 'qt3-dev-tools-embedded' (universe)
xvfb: command not found

[1]+  Exit 127                xvfb :99

Thanks for the continued help, - Dave
 
Old 04-29-2011, 12:45 PM   #10
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
Quote:
Originally Posted by laredotornado View Post
I tried your suggestion, but was unable to launch xvfb ...
Well it has to be installed before you can run it...
 
Old 04-29-2011, 01:34 PM   #11
laredotornado
Member
 
Registered: Apr 2011
Posts: 71

Original Poster
Rep: Reputation: 0
It's installed!

Code:
selenium@selenium-chi:~$ sudo apt-get install xvfb
Reading package lists... Done
Building dependency tree       
Reading state information... Done
xvfb is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 20 not upgraded.
selenium@selenium-chi:~$ 
selenium@selenium-chi:~$ xvfb :99 &
[1] 2607
selenium@selenium-chi:~$ No command 'xvfb' found, did you mean:
 Command 'qvfb' from package 'qt4-dev-tools' (main)
 Command 'qvfb' from package 'qt3-dev-tools-embedded' (universe)
xvfb: command not found

[1]+  Exit 127                xvfb :99
selenium@selenium-chi:~$

Further, I can't find an xvfb binary on my system. - Dave
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] KMail URL links spawn multiple Konqueror windows rizzy Linux - Desktop 3 02-21-2011 06:42 PM
spawn Web browser in C programme. nainesh Programming 1 09-23-2010 08:24 AM
inetd-like program that wont spawn new instances, but kills service on disconnection? PureRumble Linux - Software 0 04-28-2007 08:15 PM
Add service in windows ajkannan83 Linux - Software 2 09-12-2005 09:32 AM
A Question on Browser Sessions, and Browser Windows: opioid Programming 1 09-23-2004 02:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration