2

I want to pass two values from my PHP code to the shell command line. Something like this:

<?php
$myhost="myhost";
$mydir="mydir";
$runcommand = shell_exec("ssh $myhost du -h $mydir");
echo "<pre>$runcommand</pre>";

?>

I have tested different ways and no luck. If I hard code the values it works like a charm. This:

echo "<pre>$myhost,$mydir</pre>";

Shows both values being passed.

What am I missing?

Thank you for any assistance.

Wayne

Wayne
  • 125
  • 3
  • 1
    much esire for debugging: `$run ="ssh $myhost du -h $mydir"; echo $run; $runcommand = shell_exec($run);` –  Nov 28 '17 at 20:32
  • 1
    There is no `$myhost` or `$mydir` variable in your code. When you run it goes like: `ssh du -h`. Is that a typo ? – Kamrul Khan Nov 28 '17 at 20:34
  • 1
    i assumed that was typos as he OP says `echo "
    $myhost,$mydir
    ";` works
    –  Nov 28 '17 at 20:36
  • I am so sorry, it was a typo. My code should showed $myhost and $mydir in the big code block. – Wayne Nov 28 '17 at 21:00
  • Thank your nogad, you helped me learn a couple of new things today. Thank you for your patients with my typo. – Wayne Nov 28 '17 at 21:13

0 Answers0