I had difficulty with this so thought I'd share my code snippet.
Before
$output = shell_exec("/var/www/sites/blah/html/blahscript.sh 2>&1 $host $command");
After
$output = shell_exec("/var/www/sites/blah/html/blahscript.sh 2>&1 $host {$command}");
Adding the {}
brackets is what fixed it for me.
Also, to confirm escapeshellarg
is also needed.
$host=escapeshellarg($host);
$command=escapeshellarg($command);
Except script also needed:
set host [lindex $argv 0]
set command [lindex $argv 1]