views:

208

answers:

3

I have a php script that execute a bash script. I try to pass parameters like this:

$script="/opt/lampp/htdocs/adapt.sh"
$file="/opt/lampp/htdocs/videos/video1.mp4"
$prefix="Test"

exec ('.$script.' '.$file.' '.$prefix.');

What's wrong? How can I pass the parameters?

+2  A: 

You have your dots in the wrong place, should read:

exec ( $script . ' ' . $file . ' ' . $prefix );

or more readable

exec( "$script $file $prefix" );
Polygraf
yes, it works!! Thanks!!
skiria
A: 

I dont really understand what your question is, but your exec() call should look like this:

exec ($script.' '.$file.' '.$prefix);

If you accept parameters from outside (e.g. from a GET or POST parameter), be sure to use escapeshellarg() on the arguments for security reasons.

Pekka
Thanks, it works!
skiria
A: 

this is wrong:

exec ('.$script.' '.$file.' '.$prefix.');

be carefull with quotes :-)

exec ($script.' '.$file.' '.$prefix);
acmatos