Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. $command_save = 'mysqldump --defaults-file='.$config_file.' '.$database_name.' > '.$db_dump_file;
  2.  
  3. exec($command_save, $output = array(), $res_save);
  4.  
  5. $server = "localhost";
  6. $username = "user";
  7. $password = "pass";
  8.  
  9. $connection = ssh2_connect($server, 22);
  10.  
  11. if (ssh2_auth_password($connection, $username, $password)) {
  12.  
  13. $command = 'drush up --security-only -y';
  14.  
  15. // Run a command that will probably write to stderr (unless you have a folder named /hom)
  16. $stream = ssh2_exec($connection, $command);
  17. $errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
  18.  
  19. // Enable blocking for both streams
  20. stream_set_blocking($errorStream, true);
  21. stream_set_blocking($stream, true);
  22.  
  23. // Whichever of the two below commands is listed first will receive its appropriate output. The second command receives nothing
  24. $result = stream_get_contents($stream);
  25. $result_error = stream_get_contents($errorStream);
  26.  
  27. // Close the streams
  28. fclose($errorStream);
  29. fclose($stream);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement