I have script in /home/pi/mydir which I want to execute so first thing I need to do is
$ssh->exec('cd mydir');
and then
$ssh->exec('./script');
but it's not working so can anyone help me?
use \n :
$ssh->exec("cd mydir\n./script");
Or create a file script.sh (example) and save it in UNIX format:
cd mydir
./script
And exec this script:
$script = file_get_contents("script.sh");
$ssh->exec($script);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With