Reputation: 1158
I am running the exec command in PHP. I need to pass the variables along with it.
exec(sh myfilename.sh);
how can i pass variables to the above command ?
Upvotes: 0
Views: 55
Reputation: 37365
You can do it with
exec(escapeshellarg('/bin/sh myfilename.sh '.$key0.'='.$value0)); //e t.c.
-but to get that values, you should work with bash shell language (i.e. receive in myfilename.sh
). See this article about that. In SO, there is a great answer about that - see here.
Upvotes: 2
Reputation: 862
$v1="abc=cde";
$v2="fgh=ijk";
$v3="lmn=opq";
exec("sh myfilename.sh $v1 $v2 $v3");
Upvotes: -1