Passing multiple PHP variables to shell_exec()?
There is need to send the arguments with quota so you should use it like:
$page = shell_exec("/tmp/my_script.php '".$my_url."' '".$my_refer."'");
Exec or Shell_exec: variables don't pass from php to the script
Doubles quotes should be at the beginning of the string.
'some string "$var" somestring' // won't interpolate
"some string '$var' somestring" // will interpolate
or you can concatenate them to the string
exec('../ems-scripts/mass-email-send.sh ' . $subject . ' ' . $body, $output)
You can read this discussion Should I use curly brackets or concatenate variables within strings? your problem is more about variable concatenation and interpolation, than really about exec()
and shell_exec()
Passing GET variables to shell_exec in PHP
GET-parameters are accessed via $_GET-variable. Notice the underscore before the "GET".
http://php.net/manual/en/reserved.variables.get.php
How can I pass parameters from php to a script in linux?
! Use the function escapeshellarg
to prevent from shell injection attacks:
$asd = escapeshellarg($name);
for($i=0; $i<count($checkbox); $i++){
$raid = $checkbox[$i];
$asd = $asd ." ". escapeshellarg($raid);
}
$last_line = exec("sh /var/www/proyecto/borrarraid1.sh ". $asd, $output, $retval);
$output_delimiter = '<br/>'
if ($retval !== 0) {
echo "Error while executing command", $output_delimiter;
echo implode($output, $output_delimiter);
} else {
echo "The command was executed successfully", $output_delimiter;
echo implode($output, $output_delimiter);
}
PS: exec()
manual page: http://php.net/manual/en/function.exec.php
Related Topics
Phpexcel Auto Size Column Width
Redirect After Login on Wordpress
Getting Last Month's Date in PHP
How to Get the Subversion Revision Number in PHP
How to Build Unlimited Level of Menu Through PHP and MySQL
Request Headers Bag Is Missing Authorization Header in Symfony 2
PHP Regular Expression for Strong Password Validation
PHP 5.4 - 'Closure $This Support'
How to Run a PHP Without a Web Server
New Csrf Token Per Request or Not
Symfony 2 Entitymanager Injection in Service
How to Solve Time Out in PHPmyadmin
Using the PHP Http_Accept_Language Server Variable
Best Practice: Import MySQL File in PHP; Split Queries
Syntax Error While Defining an Array as a Property of a Class