Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> ssh2 i problem z komendą screen
kubek15
post
Post #1





Grupa: Zarejestrowani
Postów: 278
Pomógł: 3
Dołączył: 28.06.2008
Skąd: PL

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


Witam

Robie sobie panel kontrolny serwera i komendy wysyła taką funkcją

  1. if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
  2. // log in at server1.example.com on port 22
  3. if(!($con = ssh2_connect($server, 33222))){
  4. echo "fail: unable to establish connection\n";
  5. } else {
  6. // try to authenticate with username root, password secretpassword
  7. if(!ssh2_auth_password($con, "root", $password)) {
  8. echo "fail: unable to authenticate\n";
  9. } else {
  10. // allright, we're in!
  11. echo "serwer zapisany i wylaczony \n";
  12. //$stream = ssh2_exec($con, "screen -r mine" , 'vt102');
  13. //$stream = ssh2_exec($con, "stop" , 'vt102');
  14. // execute a command
  15. if (!($stream = ssh2_exec($con, $komenda))) {
  16. echo "fail: unable to execute command\n";
  17. } else {
  18. // collect returning data from command
  19. stream_set_blocking($stream, true);
  20. $data = "";
  21. while ($buf = fread($stream,4096)) {
  22. $data .= $buf;
  23. }
  24.  
  25. fclose($stream);
  26. }
  27.  
  28. }
  29. }


I niby wszystko działa bo jak wpisuje:
  1. $komenda = "cd serwer ; ls -l";

to wypisuje mi foldery , pliki też mi otwiera i jak uruchamiam coś w tle komendą screen to też się uruchamia.

Problem pojawia się wteyd gdy np. chce wejsc do teo screna co odpaliłem np. gdy wyłączam serwer.

wpisywałem
  1. $komenda= "screen -r serwer_moj; stop";
  2. //lub
  3. $komenda= "screen -r serwer_moj && stop";


i nie działa , pisze że "Must be connected to a terminal.", a przeciez się polączyłem bo inne komendy działają.

Co może być źle ?
Go to the top of the page
+Quote Post

Posty w temacie


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: 25.12.2025 - 00:41