Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: shell commands with php  (Read 3197 times)

0 Members and 1 Guest are viewing this topic.

unknown1

  • Guest
shell commands with php
« on: January 04, 2010, 01:53:49 PM »
Hello, I am trying to create a screen capture program with Xvfb server, ImageMagick and Khtml2PNG.
I seem to be having some issues and was hoping someone could help me out.

I have everything installed and working on a centos WHM/CPanel system and am able to generate the screen shots and save them to root folder from shell with the following commands.

Xvfb :2 -screen 0 1024x768x24&
export DISPLAY=localhost:2.0
khtml2png2 --sw 200 --sh 150 http://www.example.com example.png

It works 100% fine when you run it from shell.

I have created the following php script to run the exact same commands but get no results.

<?php
$connection = ssh2_connect('xxxxxxxxxxxxxx', 22);
ssh2_auth_password($connection, 'root', 'xxxxxxxxxxxxxx');

$stream = ssh2_exec($connection, 'Xvfb :2 -screen 0 1024x768x24&');
sleep(15);
$stream = ssh2_exec($connection, 'export DISPLAY=localhost:2.0');
sleep(2);
$stream = ssh2_exec($connection, 'khtml2png2 --sw 200 --sh 150 http://www.example.com example.png');
sleep(7);

echo "All done!";
?>


Does anyone know why this would work fine from shell but NOT work at all when I run it from the php script?

Thanks in advance!