1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
$temps_pause = 750000;
$sql_switch = "SELECT * FROM `switch` WHERE `type_switch`='425'";
$qur_switch = mysql_query($sql_switch);
while($dat_switch = mysql_fetch_array($qur_switch))
{
$ip_switch = $dat_switch['switch_ip'];
$resource=@ssh2_connect($ip_switch, 22);
@ssh2_auth_password($resource,"root","71Sw!tch");
@ssh2_shell($resource,"xterm");
fwrite($stdio, chr(25)); // CTRL + y
usleep($temps_pause);
fwrite($stdio, 'g'); // Menu configuration file upload/download
usleep($temps_pause);
fwrite($stdio, 'c'); // Menu Configuration file TFTP
usleep($temps_pause);
fwrite($stdio, $ip_switch.'@'.$date.'.bin'.PHP_EOL); // envoi du nom du fichier
usleep($temps_pause);
fwrite($stdio, chr(3)); // CTRL + c pour retourner au menu principal
usleep($temps_pause);
fwrite($stdio, 'c'); // interface CLI
usleep($temps_pause);
fwrite($stdio, 'conf t'.PHP_EOL); // mode configuartion du switch
usleep($temps_pause);
fwrite($stdio, 'tftp-server 10.2.1.162'.PHP_EOL); // change IP du serveur TFTP
usleep($temps_pause);
fwrite($stdio, 'exit'.PHP_EOL); // retour en mode "user"
usleep($temps_pause);
fwrite($stdio, 'copy config tftp'.PHP_EOL); // commande de trasfert
sleep(5); // longue attente
fwrite($stdio, 'exit'.PHP_EOL); // sortie de la CLI
usleep($temps_pause);
fwrite($stdio, 'l'); // commande de LOGOUT du switch dans le menu
usleep($temps_pause);
fclose($stdio); // fermeture du stream
} |
Partager