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

5
  • 1
    much esire for debugging: $run ="ssh $myhost du -h $mydir"; echo $run; $runcommand = shell_exec($run); Commented Nov 28, 2017 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 ? Commented Nov 28, 2017 at 20:34
  • 1
    i assumed that was typos as he OP says echo "<pre>$myhost,$mydir</pre>"; works Commented Nov 28, 2017 at 20:36
  • I am so sorry, it was a typo. My code should showed $myhost and $mydir in the big code block. Commented Nov 28, 2017 at 21:00
  • Thank your nogad, you helped me learn a couple of new things today. Thank you for your patients with my typo. Commented Nov 28, 2017 at 21:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.