Reputation: 1869
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?
Upvotes: 4
Views: 6698
Reputation: 449395
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.
Upvotes: 1
Reputation: 6637
this is wrong:
exec ('.$script.' '.$file.' '.$prefix.');
be carefull with quotes :-)
exec ($script.' '.$file.' '.$prefix);
Upvotes: 1
Reputation: 1006
You have your dots in the wrong place, should read:
exec ( $script . ' ' . $file . ' ' . $prefix );
or more readable
exec( "$script $file $prefix" );
Upvotes: 3