note 76389 added to function.ssh2-shell
| From: | josh at hydril dot com | Date: | Thu, 12 Jul 2007 23:49:15 +0000 |
| Subject: | note 76389 added to function.ssh2-shell | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128424@lists.php.net to get a copy of this message | ||
To run a shell script with all the variables that you would have when logged in interactively add
bash -l or sh --login infront of your command. The script I use creates a shell script, copies the
script to the box with ssh2_scp_send, then executes the script with ssh2_exec. Hope this helps
somebody.
<?php
//Example
$script1 = "bash -l /etc/rc.d/rc.httpd restart";
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$stream = ssh2_exec($connection, $script1);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 70.245.81.3
----
Manual Page -- http://www.php.net/manual/en/function.ssh2-shell.php
Edit -- https://master.php.net/note/edit/76389
Del: integrated -- https://master.php.net/note/delete/76389/integrated
Del: useless -- https://master.php.net/note/delete/76389/useless
Del: bad code -- https://master.php.net/note/delete/76389/bad+code
Del: spam -- https://master.php.net/note/delete/76389/spam
Del: non-english -- https://master.php.net/note/delete/76389/non-english
Del: in docs -- https://master.php.net/note/delete/76389/in+docs
Del: other reasons-- https://master.php.net/note/delete/76389
Reject -- https://master.php.net/note/reject/76389
Search -- https://master.php.net/manage/user-notes.php