PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
s3rg1o
Forum Commoner
Posts: 32 Joined: Sun Feb 16, 2003 4:58 pm
Post
by s3rg1o » Wed Feb 26, 2003 3:22 pm
hey guys, I am hoping I can get some help from this forum, you guys helped me out before
ok so I am attempting to execute an outside app from php.. with exec or system and neither is working
here is what works
Code: Select all
<?
$output = system ("ls -l");
echo $output;
?>
same with exec()
but if I do something like....
Code: Select all
<?
$output = system ("mogrify -resize 640x480 shot0000.jpg");
echo $output;
?>
it will not do it, I know I am pointing to the right directory and everything aswell and I know that safe_mode is off in the php.ini
any suggestions? thanks
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed Feb 26, 2003 4:11 pm
does it not return or does it not perform the expected action?
I know I am pointing to the right directory
I do not see any path at all, is
mogrify in one of the directories set by PATH for the webserver-account?
Is there anything in $output? And what should it be?
s3rg1o
Forum Commoner
Posts: 32 Joined: Sun Feb 16, 2003 4:58 pm
Post
by s3rg1o » Wed Feb 26, 2003 4:26 pm
hey vokla I believe you helped me with my problem I had before
and yeh I changed it so that it points to mogrify's path
Code: Select all
<?php
exec ('/home/web/pcgs/convert/utilities/mogrify -resize 640x480 /home/web/pcgm/shot0000.jpg', $output);
$output = ereg_replace ("\n", "<BR>", $outputї0]);
echo $output;
?>
also, when I take out the modifiers
Code: Select all
<?php
exec ('/home/web/pcgs/convert/utilities/mogrify', $output);
$output = ereg_replace ("\n", "<BR>", $outputї0]);
echo $output;
?>
it does print out the same thing that it does on the command prompt telling me to add what I need to add to the command but it's when I actually add the -resizing that it just will not work
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed Feb 26, 2003 4:48 pm
hm.. what was the solution last time?
Stoker
Forum Regular
Posts: 782 Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:
Post
by Stoker » Wed Feb 26, 2003 5:31 pm
the returned value is just the last line when using exec(), try something like
@exec('/bin/ls -l /home/user/dirtolist',$output);
echo "Output: <pre>\n". join('',$output);
if you are passing any commandline arguments from your script, make sure to always use escapeshelllarg() !!!
s3rg1o
Forum Commoner
Posts: 32 Joined: Sun Feb 16, 2003 4:58 pm
Post
by s3rg1o » Wed Feb 26, 2003 5:51 pm
Stroker, it didn't work
Code: Select all
<?php
escapeshellarg ('/home/web/pcgs/convert/utilities/mogrify -resize 640x480 /home/web/pcgm/shot0000.jpg', $output);
$output = ereg_replace ("\n", "<BR>", $outputї0]);
echo $output;
?>
s3rg1o
Forum Commoner
Posts: 32 Joined: Sun Feb 16, 2003 4:58 pm
Post
by s3rg1o » Wed Feb 26, 2003 5:52 pm
volka wrote: hm.. what was the solution last time?
the solution was to a completely different problem
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed Feb 26, 2003 9:56 pm
appending 2>&1 to the command revealed a filesystem permission problem. Would be nice if exec could fetch stderr on its own (maybe via flag parameter)