Find the answer to your Linux question:
Results 1 to 3 of 3
Hello all, Im trying to execute firefox from a webserver so I can take a snapshot of a site in the bowser. I have written a bash script to execute ...
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    2

    Launching Firefox from Bash Script

    Hello all,

    Im trying to execute firefox from a webserver so I can take a snapshot of a site in the bowser. I have written a bash script to execute firefox and create the image, everything works fine on the command line though vnc, but when I execute the script through an shell exec() command, everything runs fine except firefox. I get no errors back and no processes of firefox have even started.

    I have switched to opera to make sure it was just firefox, and opera works fine as well as several other Xapps (xclock, gnome-calc, gnome-terminal) that I have tested. I would like to use firefox because it renders a little cleaner than opera, but Im running out of things to try.

    Any suggestions?

    Is there anyway that I can try to pull an error out of firefox?

    heres the bash script:

    Code:
    #!/bin/bash
    
    export XAUTHORITY=/home/user/.Xauthority
    export DISPLAY=:2.0
    xhost +
    
    /usr/lib/firefox-3.08/firefox --display=:2.0 -width 1024 -height 768 &
    sleep 5
    
    import -display :2.0 -w root $3 &
    sleep 2
    
    killall -9 firefox
    killall -9 firefox-bin &
    sleep 1

  2. #2
    Just Joined! jaysunn's Avatar
    Join Date
    Apr 2009
    Location
    New York City - USA
    Posts
    18
    Remove the --display=:2.0


    This will remove your Error: cannot open display:



    Hope this helps.

    jaysunn

  3. #3
    Just Joined!
    Join Date
    Apr 2009
    Posts
    2
    Thanks for the reply and sorry for not getting back to this forum - ive updated the others I asked this question in. The display is not the problem - i had set a specific display just for that user for this script.

    The problem was that when executing this script from the web, the env variables were not the same as executing on the command line from vnc, even though I was the same user. I added this code to the beginning of the script and all is well now. Fire fox was trying to find the .profile directory in /.

    Code:
    export HOME=/home/user

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...