<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Script blade using SSH by PHP in BladeSystem - General</title>
    <link>https://community.hpe.com/t5/bladesystem-general/script-blade-using-ssh-by-php/m-p/6592994#M19619</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm try to configure many blade server on few C7000 enclosure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm correctly conected to my enclosure but each time when i try to connect on one blade i'm directly disconected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;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]&amp;gt; connect server 6


Connecting to bay 6 ...

Connection terminated by user's session.


OA-10604BA3D313 [SCRIPT MODE]&amp;gt;  set /system1 oemhp_servername=wxcvbn 


Invalid Arguments

&lt;/PRE&gt;&lt;P&gt;How can i fix my trouble with :&lt;/P&gt;&lt;PRE&gt;Connection terminated by user's session.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my php code :&lt;/P&gt;&lt;PRE&gt;&amp;lt;?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 '&amp;lt;pre&amp;gt;' . $ret . '&amp;lt;/pre&amp;gt;';

?&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks by advance or your help.&lt;/P&gt;</description>
    <pubDate>Fri, 29 Aug 2014 10:29:55 GMT</pubDate>
    <dc:creator>Marcbis</dc:creator>
    <dc:date>2014-08-29T10:29:55Z</dc:date>
    <item>
      <title>Script blade using SSH by PHP</title>
      <link>https://community.hpe.com/t5/bladesystem-general/script-blade-using-ssh-by-php/m-p/6592994#M19619</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm try to configure many blade server on few C7000 enclosure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm correctly conected to my enclosure but each time when i try to connect on one blade i'm directly disconected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;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]&amp;gt; connect server 6


Connecting to bay 6 ...

Connection terminated by user's session.


OA-10604BA3D313 [SCRIPT MODE]&amp;gt;  set /system1 oemhp_servername=wxcvbn 


Invalid Arguments

&lt;/PRE&gt;&lt;P&gt;How can i fix my trouble with :&lt;/P&gt;&lt;PRE&gt;Connection terminated by user's session.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my php code :&lt;/P&gt;&lt;PRE&gt;&amp;lt;?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 '&amp;lt;pre&amp;gt;' . $ret . '&amp;lt;/pre&amp;gt;';

?&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks by advance or your help.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Aug 2014 10:29:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/bladesystem-general/script-blade-using-ssh-by-php/m-p/6592994#M19619</guid>
      <dc:creator>Marcbis</dc:creator>
      <dc:date>2014-08-29T10:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Script blade using SSH by PHP</title>
      <link>https://community.hpe.com/t5/bladesystem-general/script-blade-using-ssh-by-php/m-p/6605234#M19626</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nobody have an explaination about "connexion teminated by user's session" just after this command :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;connect server "nbr"\n set /system1 oemhp_servername="servername"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even if i remove 'set /system ...' i have the same issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;help please .....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;MarC.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2014 15:23:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/bladesystem-general/script-blade-using-ssh-by-php/m-p/6605234#M19626</guid>
      <dc:creator>Marcbis</dc:creator>
      <dc:date>2014-09-08T15:23:48Z</dc:date>
    </item>
  </channel>
</rss>

