0

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 ?

sandy
  • 1,096
  • 1
  • 7
  • 17

2 Answers2

2

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.

Community
  • 1
  • 1
Alma Do
  • 36,374
  • 9
  • 70
  • 101
-1
$v1="abc=cde";
$v2="fgh=ijk";
$v3="lmn=opq";
exec("sh myfilename.sh $v1 $v2 $v3");
Gar
  • 852
  • 12
  • 19