Page 1 of 1
shell_exec issues
Posted: Sat Apr 15, 2006 5:42 pm
by d3ad1ysp0rk
Hey everyone. Need a bit of help.
Code: Select all
<?php
$pwdOutput = shell_exec("pwd");
$sOutput = shell_exec("convert ../images/team//24antilame.gif -thumbnail 60x40 ../images/team//thumbs/24antilame.gif");
echo "PWD: " . $pwdOutput . "<br />";
echo "Out: " . $sOutput;
die();
?>
Alright, here's the deal. If I execute that code, I get this:
Code: Select all
Pwd: /home/sites/site45/web/control
Out:
So; no output. Not a big deal, because when you use convert (imageMagick), it shouldn't spit anything out. Here's the problem though; it doesn't actually do the conversion (create a thumbnail).
So I'm thinking "maybe I messed up the syntax of the call..", but no.. when I cd to what pwd prints out, and then paste the exact call I'm sending to shell_exec, it works.
Any ideas? This is so confusing..

Posted: Sat Apr 15, 2006 6:55 pm
by R4000
try
passthru().
I use it for everything like this...
passthru
(PHP 3, PHP 4, PHP 5)
passthru -- Execute an external program and display raw output
Description
void
passthru ( string command [, int &return_var] )
The
passthru() function is similar to the
exec() function in that it executes a command. This function should be used in place of
exec() or system() when the output from the Unix command is binary data which needs to be passed directly back to the browser. A common use for this is to execute something like the pbmplus utilities that can output an image stream directly. By setting the Content-type to image/gif and then calling a pbmplus program to output a gif, you can create PHP scripts that output images directly.
Parameters
command
The command that will be executed.
return_var
If the return_var argument is present, the return status of the Unix command will be placed here.
Posted: Sat Apr 15, 2006 7:54 pm
by d3ad1ysp0rk
Changing it to
printed this result: "127"
I googled it, and it seems like a php OR imagemagick error, stating "file not found" or something..
team directory is "drwxrwxrwx" as is thumbs directory.
Any ideas? :\
Posted: Sat Apr 15, 2006 8:38 pm
by feyd
does
getcwd() say something different than `pwd` ?
Posted: Sat Apr 15, 2006 8:45 pm
by d3ad1ysp0rk
Unfortunately no,
Code: Select all
Cwd: /home/sites/site45/web/control
Pwd: /home/sites/site45/web/control
Posted: Sat Apr 15, 2006 10:37 pm
by timvw
Is the convert tool in your webservers path?
Posted: Sat Apr 15, 2006 10:51 pm
by d3ad1ysp0rk
timvw wrote:Is the convert tool in your webservers path?
I'm not the sysadmin, and I'm no unix pro.. where would the config file for finding out be?
Posted: Sun Apr 16, 2006 5:03 am
by R4000
passthru() outputs the raw data, i don't know what format this might be in, cause personaly... ive never needed output from a command line app.
If it can't be done in PHP then do it in another language, don't split it across two xD
ImageMagik is a nice application, but if you just want the resize stuff.. use GD, same for convert.
Posted: Sun Apr 16, 2006 9:57 am
by d3ad1ysp0rk
R4000 wrote:passthru() outputs the raw data, i don't know what format this might be in, cause personaly... ive never needed output from a command line app.
If it can't be done in PHP then do it in another language, don't split it across two xD
ImageMagik is a nice application, but if you just want the resize stuff.. use GD, same for convert.
GD isn't installed, and there is no way for it to be at this time. The site needs to go live, so I need to use what's available.
I don't really understand how I'm splitting it across languages; I'm letting the user upload an image which I'm resizing with imagemagick. MagickWand for PHP isn't installed, so I need to use the command line version..
Also, I still haven't figured out whether it's in apache's path, so how would I find that out?
Posted: Sun Apr 16, 2006 1:33 pm
by d3ad1ysp0rk
Incase anyone finds this by searching and wants to know the solution;
Apache could not find the program. To rectify this, you just need to specify the exact path.
The reason I did not try this to begin with is because I had no idea where it was located. I found out by searching through other sites on the same server and finding their image thumbnailing code.
Thanks for the help everyone