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 37 38
| //Importation de la base courante
print "-------------------------------------------------- <br>";
print "Exportation <br>";
print "--------------------------------------------------<br>";
//récupération et formattage de la date
$day=date('d');
$month=date('m');
$year=date('y');
$date=$day.'_'.$month.'_'.$year;
//initialisation de la connection au serveur distant via SSH
if($connection = ssh2_connect('localhost',22))
{
print "Succès : connection réussie <br>";
//identification aupres du serveur distant
if(ssh2_auth_password($connection, 'boris', 'infodb'))
{
print "Succès : authentification réussie <br><br>";
//création du shell intéractif
print "Exportation de la base courante... <br>";
$shell = ssh2_shell($connection,"xterm");
$cmd="exp system/manager@$nom_base file='$destination\\$nom_base\\$nom_base.dmp' full=y statistics=none log='$destination\\$nom_base\\log.log' \n";
//envoie des commandes
fwrite($shell, $cmd);
sleep( 50 );
//affichage des resusltats du shell
while( $line = fgets( $shell, 4096 ) )
{
$feedback=$feedback.' '.$line;
}
fclose($shell);
print "$feedback <br><br>"; |
Partager