Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Linux ajax połaczenie ze screen
Forum PHP.pl > Forum > PHP
xxdrago
Witam, jak najlepiej rozwiązać problem połączenia się ze strony www do serwera linux a dokładnie do wirtualnego terminala z możliwością wysyłania komend?

Na razie mam coś takiego:

  1. require_once 'conf.php'; // Plik Konfiguracyjny
  2. set_include_path('C:\xampp\htdocs\class\ssh');
  3. ini_set('include_path', 'C:\xampp\htdocs\class\ssh');
  4. include('class/ssh/Net/SSH2.php');
  5. include('class/ssh/File/ANSI.php');
  6.  
  7.  
  8.  
  9.  
  10. $ssh = new Net_SSH2($ip,$port);
  11. if (!$ssh->login($login, $haslo)) {
  12. exit('Login Failed');
  13. }
  14.  
  15. //echo $ssh->exec('screen -R terminal');
  16. $ansi = new File_ANSI();
  17.  
  18. $ansi->appendString($ssh->read('admin@home:~$'));
  19. $ssh->write("screen -R et\n");
  20. //$ssh->setTimeout(1);
  21. $ssh->write("status\n");
  22. $ansi->appendString($ssh->read());
  23. echo $ansi->getScreen(); // outputs HTML



  1. <!doctype html>
  2. <html lang="en">
  3. <meta charset="utf-8">
  4. <title>load demo</title>
  5. body {
  6. font-size: 12px;
  7. font-family: Arial;
  8. }
  9. </style>
  10. <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
  11. </head>
  12.  
  13. <div id="success"></div>
  14. <div id="error"></div>
  15. <div id="loading">
  16. <p><img src="19.gif" /> Please Wait</p>
  17. </div>
  18.  
  19. $(document).ajaxStart(function(){
  20. $('#loading').show();
  21. }).ajaxStop(function(){
  22. $('#loading').hide();
  23. });
  24.  
  25. $( "#success" ).load( "/terminal.php", function( response, status, xhr ) {
  26. if ( status == "error" ) {
  27. var msg = "Sorry but there was an error: ";
  28. $( "#error" ).html( msg + xhr.status + " " + xhr.statusText );
  29. }
  30. });
  31.  
  32. </body>
  33. </html>


Myślałem, odświeżać w ajaxie po prostu plik z kodem przykładowo co 5 sekund, ale chyba nie będzie to dobre rozwiązanie?

LowiczakPL
jest coś takiego jak jQuery terminal

instalacja na 2 sposoby

bower install jquery.terminal

albo

npm install --save jquery.terminal


a na Google Code masz projekt Xwiterm

https://code.google.com/archive/p/xwiterm/
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.