How to call bash script from php transfer parameters

I have a php script that execute a bash script. I am trying to pass such parameters:

$script="/opt/lampp/htdocs/adapt.sh" $file="/opt/lampp/htdocs/videos/video1.mp4" $prefix="Test" exec ('.$script.' '.$file.' '.$prefix.'); 

What happened? How to pass parameters?

+4
source share
3 answers

You have points in the wrong place, you should read:

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

or more readable

 exec( "$script $file $prefix" ); 
+3
source

I really don't understand what your question is, but your call to exec () should look like this:

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

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

+1
source

it is not right:

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

be careful with quotation marks :-)

 exec ($script.' '.$file.' '.$prefix); 
+1
source

Source: https://habr.com/ru/post/1309653/


All Articles