4

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?

1
  • 1
    You can already spot what is wrong by just looking on how your syntax is highlighted... Commented May 13, 2010 at 10:40

3 Answers 3

3

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

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

or more readable

exec( "$script $file $prefix" );
Sign up to request clarification or add additional context in comments.

Comments

1

this is wrong:

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

be carefull with quotes :-)

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

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.