Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Linux ajax połaczenie ze screen
xxdrago
post
Post #1





Grupa: Zarejestrowani
Postów: 654
Pomógł: 42
Dołączył: 27.07.2010
Skąd: Jaworzno

Ostrzeżenie: (0%)
-----


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?

Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
LowiczakPL
post
Post #2





Grupa: Zarejestrowani
Postów: 531
Pomógł: 55
Dołączył: 3.01.2016
Skąd: Łowicz

Ostrzeżenie: (0%)
-----


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/
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 08:17