2
Example:
<?php
$param=array(valor, valor2, valor3);
$return = shell_exec("sh teste.sh $param");
echo "<pre>$return</pre>";
?>
Shell script:
#!/bin/bash
param=$1
echo $param
That way only the word returns to me array
, I tried to receive as array but it did not work.
gave just right!!!
– Robert Sousa
the guard section the content did not work, has another form of guard in a variable?
– Robert Sousa
@Robertsousa To keep everything in one variable I only know this way
– hkotsubo
solve like this: COUNT=$(echo $@ | awk '{print $1;}') separating the values and counting in for
– Robert Sousa
but besides the array, I wanted to pass two more variables and the array, but it messes up when I get in shell_script, $1 and $2 $@that way, but in $1 and $2 comes the array too!!
– Robert Sousa
@Robertsousa The shell script takes all the arguments at once and it has no way of knowing what was an array before and what wasn’t (pro script is all a large list of parameters), since PHP knew that. If you want to separate specific arguments into their own variables, you have to do it manually - search about
shift
, maybe that’s what you need– hkotsubo
I also suggest to search here on the site, and if there is not something like that, there is the case of ask another question :-)
– hkotsubo