phpssh2-exec

Im using ssh2_exec functionin php why it doesn't pass more then 3 parameters?


Why the ssh2_exec function doesn't pass more than three parameters?

$stream_1 = ssh2_exec($ssh, "/root/Script/Auto_Traces/show_ng_trace.sh $a $b $c $d $e");

In this case only $a $b $c are passing but not $d and $e, how can I solve it?


Solution

  • I suspect there are spaces in some of the first 3 variables, so they're being treated as multiple arguments. Then the last 2 arguments are being ignored. In case any of the variables have spaces (or other special characters) in them, you should escape them.

    $ae = escapeshellarg($a);
    $be = escapeshellarg($b);
    // repeat for the rest of variables
    $stream_1 = ssh2_exec($ssh, "/root/Script/Auto_Traces/show_ng_trace.sh $ae $be $ce $de $ee");