Jump to content

The exec() call does not work from Web server


krishnanunni

Recommended Posts

Hi all,

I am a newbie to PHP. I'm trying to execute a program from my PHP script by calling the exec() function of PHP. It works fine when i try it from command line, or execute the script in command line. But when i call it from a php script in my apache, it does nothing. No errors are thrown. What i get in return is only an empty array. i'm using Ubuntu 11.10 and Apache 2.2 with PHP 5.3.3 :(

 

thanks for helping me.

Link to comment
Share on other sites

<?php

$htmlcontent=$_POST['source'];

$pngname=$_POST['pngname'];

$height=$_POST['height'];

$width=$_POST['width'];

 

if(!isset($htmlcontent)){die('No HTML Cannot Proceed');}

$sourcefile='/var/www/CutyCapt/Sources/sourcefile.html';

$pngfile='/var/www/CutyCapt/Captures/'.$pngname;

$hyperlink='http://my.domain.com/CutyCapt/Captures/'.$pngname;

 

$htmlfile=fopen($sourcefile,'w') or die('Source Initialization Failed');

fwrite($htmlfile,$htmlcontent);

fclose($htmlfile);

if(!file_exists($sourcefile)){die('Parser Source Does not Exist! Operation aborted');}

 

//Generate SnapShot

shell_exec('/usr/bin/CutyCapt --html='.$sourcefile.' --out='.$pngfile.' --min-height='.$height.' --min-width='.$width);

//shell_exec('/usr/bin/CutyCapt --html=source.htm --out=test.png --min-height=600 --min-width=800');

 

if(!file_exists($pngfile)){die('Image Not Created');}

else

echo $hyperlink;

?>

 

This is my code. This can work fine, when i try from terminal, with php interpreter the script works fine. But when it comes to webserver, it wont execute at all. All libs and CutyCapt resides in /usr/bin/ only. Any suggestions?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.