BladeSystem - General
cancel
Showing results for 
Search instead for 
Did you mean: 

Script blade using SSH by PHP

Marcbis
Regular Visitor

Script blade using SSH by PHP

Hi,

 

I'm try to configure many blade server on few C7000 enclosure.

 

i'm correctly conected to my enclosure but each time when i try to connect on one blade i'm directly disconected.

 

User:OAtmp-Administrator-54003E7C logged-in to 
HP BladeSystem Onboard Administrator
(C) Copyright 2006-2014 Hewlett-Packard Development Company, L.P.

OA-10604BA3D313 [SCRIPT MODE]> connect server 6


Connecting to bay 6 ...

Connection terminated by user's session.


OA-10604BA3D313 [SCRIPT MODE]>  set /system1 oemhp_servername=wxcvbn 


Invalid Arguments

How can i fix my trouble with :

Connection terminated by user's session.

 

Here is my php code :

<?php
 function ssh($host, $login, $mdp, $command)
 {
  if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
   if(!($con = ssh2_connect($host, 22))){
   echo "échec connexion\n";
   }
  else {
   if(!ssh2_auth_password($con, $login, $mdp)) {
            echo "échec authentification\n";
   }
   else {
    // execute a command
    if (!($stream = ssh2_exec($con, $command ))) {
     echo "échec de l'exécution de la commande\n";
    } 
    else {
     // collect returning data from command
     stream_set_blocking($stream, true);
     $data = "";
     while ($buf = fread($stream,4096)) {
      $data .= $buf;
     }
     fclose($stream);
     return $data;
    }
   }
  }
 }

 $ch = $_SESSION['c'];
 $la = $_SESSION['l'];
 $no = $_SESSION['n'];

 include ('base_sql.php'); //infos de connexion à la base SQL
    
   $sql = "SELECT IP_OA FROM `enclosure` WHERE NOM = '$ch'";
   $req = mysql_query($sql);
   while($ip_enclosure=mysql_fetch_array($req))
      $ipc = $ip_enclosure['IP_OA'];
   
$command = "connect server ".$la."\n set /system1 oemhp_servername=".$no." ";


$ret = ssh($ipc, 'Admin_account', 'password', $command);
echo '<pre>' . $ret . '</pre>';

?>

 

Thanks by advance or your help.

1 REPLY
Marcbis
Regular Visitor

Re: Script blade using SSH by PHP

Hi,

 

Nobody have an explaination about "connexion teminated by user's session" just after this command :

 

connect server "nbr"\n set /system1 oemhp_servername="servername"

 

Even if i remove 'set /system ...' i have the same issue.

 

help please .....

 

Rgds,

MarC.