ssh2_exec() with sudo - Help with multiple command string

Hello:

I would like to ask for your expertise.

For some time I have been working on a project to maintain remote servers via php. I have managed to pass commands by performing the following:

[php]
$connection = ssh2_connect($ip , 22);
$authentication = ssh2_auth_password($connection, ‘usrname’ , ‘password’);
$execute = ssh2_exec($connection, ‘echo password | sudo -S command_to_send’;
[/php]

but if I try this:
[php]
$connection = ssh2_connect($ip , 22);
$authentication = ssh2_auth_password($connection, ‘usrname’ , ‘password’);
$execute = ssh2_exec($connection, ‘echo password | sudo -S command1_to_send; echo password | sudo -S command2_to_send;’;
[/php]
The second command seems not to run… I am not getting errors either… So I am at a loss here. Am I doing something wrong?

Thanks!

HTakeuchi

Sponsor our Newsletter | Privacy Policy | Terms of Service