exec() problem.

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

Post Reply
loozi
Forum Newbie
Posts: 10
Joined: Sun Feb 24, 2008 4:04 am

exec() problem.

Post by loozi »

hello, I'm having some problems with exec() under windows.

this code works perfectly

Code: Select all

 
 
$r2 = exec('start /D C:\php\ffmpeg\ /B ffmpeg.exe -i testvid.wmv -vhook "./vhook/imlib2.dll -i log.png" -y testvidwm.wmv , $f);
 
 
but when I try doing this:

Code: Select all

 
 
$vidf = 'testvid.wmv';
$wmvid = 'testvidwm.wmv';
$wmfile = 'log.png';
 
$r2 = exec('start /D C:\php\ffmpeg\ /B ffmpeg.exe -i $vidf -vhook "./vhook/imlib2.dll -i $wmfile" -y $wmvid' , $f);
 
 
it just stops working, any ideas? thanks in advance :)
loozi
Forum Newbie
Posts: 10
Joined: Sun Feb 24, 2008 4:04 am

Re: exec() problem.

Post by loozi »

no one knows? why isn't exec() working properly with variables?
Drachlen
Forum Contributor
Posts: 153
Joined: Fri Apr 25, 2003 1:16 am

Re: exec() problem.

Post by Drachlen »

Try this:

Code: Select all

 $vidf = 'testvid.wmv';
$wmvid = 'testvidwm.wmv';
$wmfile = 'log.png';
 
$r2 = exec('start /D C:\php\ffmpeg\ /B ffmpeg.exe -i '.$vidf.' -vhook "./vhook/imlib2.dll -i '.$wmfile.'" -y '.$wmvid , $f); 
 
The importance here is that when a variable is surrounded by single quotes ('...') it is not parsed as a variable.

Example 1:

Code: Select all

 $var = "world";
echo 'hello $var'; 
Output:

Code: Select all

 hello $var 

Example 2:

Code: Select all

$var = "world";
echo "hello $var";
Output:

Code: Select all

hello world

The solution in your case is to simply break the string up so the variables can be interpreted properly.

Hope that helps.
loozi
Forum Newbie
Posts: 10
Joined: Sun Feb 24, 2008 4:04 am

Re: exec() problem.

Post by loozi »

Nevermind! works perfectly, was doing something wrong. Thanks Drachlen :) .
Drachlen
Forum Contributor
Posts: 153
Joined: Fri Apr 25, 2003 1:16 am

Re: exec() problem.

Post by Drachlen »

Run this and paste what it says

Code: Select all

 
$vidf = 'testvid.wmv';
$wmvid = 'testvidwm.wmv';
$wmfile = 'log.png';
$out = array();
$return = 0;
$r2 = exec('start /D C:\php\ffmpeg\ /B ffmpeg.exe -i '.$vidf.' -vhook "./vhook/imlib2.dll -i '.$wmfile.'" -y '.$wmvid , $out, $return); 
 
echo "return: ".$return;
print_r($out);
 
Edit: Okay, great.

Good luck.
Post Reply