linux - How to capture x screen using PHP, shell_exe and scrot -


I am making a web page screen capture application for internal R & D projects.

Environment: Ubuntu 9.04 (default desktop installation), Apache, PP.

By now I've got a Bash script that takes a parameter (URL), spreads Firefox, grabs the screen and saves it as PNG. I have tried to run it from the terminal and it works fine.

Here is the Bash script:

  #! / Bin / bash Firefox $ 1 # Start Firefox and grab the screen with the delay of # 5 seconds passed in the URL scroll-d 5 test.png  

Next I have a simple PHP page is created which uses shell_exec to run the script:

  & lt;? // sample url $ url = 'http://www.google.com'; // run the script shell_exec ('sh script.sh'. $ Url); // put HTML to display the out image 'echo' & lt; Img src = "test.png" / & gt; '; ? & Gt;  

However, when the PHP page is called then the screen is not captured. A quick result in Apache error logs shows the following message:

  Error: No performance specified error: X can not open the display it is * Running, yes  

I'm guessing this because Apache is running as a different user and does not have access to my X display.

So, anyone can mislead me or put a light on how I can capture current user performance.

Thank you.

  • A PHP webpage (which runs under Apache) Receives; For example, some such form, whose example
    • contains the URL in a database-like system, which will be used as a queue
    • This URL is "processed" "
  • A PHP (or other language) script, completely independent from Apache; For example, started by cronat
    • This script selects a URL from the queue in the database (for example, at least one), and it marks it as "processing"
    • Your shell-script, which launches Firefox and screenshots
    • A screenshot is made, the URL in the queue is marked as "done", and The screenshot path is linked to the URL
    • This will work, because it is free from Apache
    • Another web page displays the queue, and the status of each URL (the "process "," Processing "," Path to Screenshots + "+
      • You can visualize any organization through the user and a URL to not display every url + screenshot to anyone.

      With this system, many advantages:

      • php + apache for webpages
      • You can have webpages on one server
      • and you may have several machines (Linux, windows) for php
      • "System" parts outside of Apache
      • Better than scales ^^
      • < / Ul>

      This is not really the answer to the question, but I think this is a better way ... hope That helps!


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -