Magellan Linux

Diff of /alx-src/branches/alx-web-060/include/common-functions.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2416 by niro, Wed Jun 15 14:17:26 2011 UTC revision 2417 by niro, Wed Jun 15 14:19:07 2011 UTC
# Line 7  function sshdo($cmd, $ip, $user="root") Line 7  function sshdo($cmd, $ip, $user="root")
7   global $privkey_file;   global $privkey_file;
8   global $pubkey_file;   global $pubkey_file;
9    
10   if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist. You must install the ssh2 module from pecl library!");   if (!function_exists("ssh2_connect")) die("sshdo(): function ssh2_connect doesn't exist. You must install the ssh2 module from pecl library!");
11    
12   if(!($con = ssh2_connect($ip, "22")))   if(!($con = ssh2_connect($ip, "22")))
13   {   {
14   echo "failure, could not connect\n";   echo "sshdo(): failure, could not connect\n";
15   }   }
16   else   else
17   {   {
18   if(!ssh2_auth_pubkey_file($con, $user, $pubkey_file, $privkey_file))   if(!ssh2_auth_pubkey_file($con, $user, $pubkey_file, $privkey_file))
19   {   {
20   echo "failure, could not login\n";   echo "sshdo(): failure, could not login\n";
21   }   }
22   else   else
23   {   {
24   echo "logged in\n";   //echo "logged in\n";
25    
26   if(!($stream = ssh2_exec($con, "source /etc/profile; ".$cmd."; echo '__RETVAL__:'$?")))   if(!($stream = ssh2_exec($con, "source /etc/profile; ".$cmd."; echo '__RETVAL__:'$?")))
27   {   {
28   echo "failure, could not execute command '".$cmd."'\n";   echo "sshdo(): failure, could not execute command '".$cmd."'\n";
29   }   }
30   else   else
31   {   {

Legend:
Removed from v.2416  
changed lines
  Added in v.2417