Pagina 1 di 5 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 41
  1. #1

    Phpselib Nascondere output Aiuto!

    Salve a tutti,
    Sto utilizzando il pacchetto phpselib per le connessioni ssh2 tramite php.

    Ora con la funzione ssh2_exec è possibile eseguire dei comandi alla shell che ci si connette.
    Il mio problema è che , eseguendo i comandi, mi visualizza l'output della shell.

    Mi servirebbe che l'output venisse nascosto.in modo da mostrarmi solo la barra di progressione come nelle immagini.
    .

    Ho provato ad eliminare la parte di codice che richiama l'output ma lo script mi rimanda alla pagina già a processo completato e quindi con la barra di progressione già a 100%




    Vi ringrazio in anticipo per l'aiuto.

  2. #2
    Utente di HTML.it L'avatar di _debo
    Registrato dal
    Mar 2012
    residenza
    London, UK
    Messaggi
    858
    Non ho mai usato quell'estensione ma possiamo vedere di fare comunque qualcosa.
    È possibile vedere la porzione di codice che ti sta dando problemi per favore?

  3. #3
    Questo è il codice della mia pagina

    Codice PHP:
    usleep(350000); update_progress(7); echo "<font color='red'><center>Download IRCD...</center></font>"; echo $ssh->exec('wget [url]http://www.unrealircd.com/downloads/Unreal3.2.9.tar.gz[/url]'); usleep(150000); update_progress(71); echo "<font color='red'><center>Scompattamento IRCD...</center></font>"; echo $ssh->exec('tar -zxvf Unreal3.2.9.tar.gz'); usleep(1150000); update_progress(100); } 
    Codice PHP:
    function exec($command$block true) { if (!($this->bitmap NET_SSH2_MASK_LOGIN)) { return false; } // RFC4254 defines the (client) window size as "bytes the other party can send before it must wait for the window to // be adjusted". 0x7FFFFFFF is, at 4GB, the max size. technically, it should probably be decremented, but, // honestly, if you're transfering more than 4GB, you probably shouldn't be using phpseclib, anyway. // see [url]http://tools.ietf.org/html/rfc4254#section-5.2[/url] for more info $this->window_size_client_to_server[NET_SSH2_CHANNEL_EXEC] = 0x7FFFFFFF; // 0x8000 is the maximum max packet size, per [url]http://tools.ietf.org/html/rfc4253#section-6.1,[/url] although since PuTTy // uses 0x4000, that's what will be used here, as well. $packet_size = 0x4000; $packet = pack('CNa*N3', NET_SSH2_MSG_CHANNEL_OPEN, strlen('session'), 'session', NET_SSH2_CHANNEL_EXEC, $this->window_size_client_to_server[NET_SSH2_CHANNEL_EXEC], $packet_size); if (!$this->_send_binary_packet($packet)) { return false; } $this->channel_status[NET_SSH2_CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_OPEN; $response = $this->_get_channel_packet(NET_SSH2_CHANNEL_EXEC); if ($response === false) { return false; } // sending a pty-req SSH_MSG_CHANNEL_REQUEST message is unnecessary and, in fact, in most cases, slows things // down. the one place where it might be desirable is if you're doing something like Net_SSH2::exec('ping localhost &'). // with a pty-req SSH_MSG_CHANNEL_REQUEST, exec() will return immediately and the ping process will then // then immediately terminate. without such a request exec() will loop indefinitely. the ping process won't end but // neither will your script. // although, in theory, the size of SSH_MSG_CHANNEL_REQUEST could exceed the maximum packet size established by // SSH_MSG_CHANNEL_OPEN_CONFIRMATION, RFC4254#section-5.1 states that the "maximum packet size" refers to the // "maximum size of an individual data packet". ie. SSH_MSG_CHANNEL_DATA. RFC4254#section-5.2 corroborates. $packet = pack('CNNa*CNa*', NET_SSH2_MSG_CHANNEL_REQUEST, $this->server_channels[NET_SSH2_CHANNEL_EXEC], strlen('exec'), 'exec', 1, strlen($command), $command); if (!$this->_send_binary_packet($packet)) { return false; } $this->channel_status[NET_SSH2_CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_REQUEST; $response = $this->_get_channel_packet(NET_SSH2_CHANNEL_EXEC); if ($response === false) { return false; } $this->channel_status[NET_SSH2_CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_DATA; if (!$block) { return true; } $output = ''; while (true) { $temp = $this->_get_channel_packet(NET_SSH2_CHANNEL_EXEC); switch (true) { case $temp === true: return $output; case $temp === false: return false; default: $output.= $temp; } } } 
    Questo è il codice incluso dal phpselib

    Se elimino la parte dell'output

    Codice PHP:
    $output ''; while (true) { $temp $this->_get_channel_packet(NET_SSH2_CHANNEL_EXEC); switch (true) { case $temp === true: return $output; case $temp === false: return false; default: $output.= $temp; } } 
    Mi dà quel problema.

  4. #4
    Utente di HTML.it L'avatar di _debo
    Registrato dal
    Mar 2012
    residenza
    London, UK
    Messaggi
    858
    Ma la formattazione del codice? Ti odio con affetto

  5. #5
    Utente di HTML.it L'avatar di _debo
    Registrato dal
    Mar 2012
    residenza
    London, UK
    Messaggi
    858
    Perdonami ma mi rifiuto di mettere le mani a quel codice. Puoi reinviarlo formattato a modo per favore?

  6. #6
    Utente di HTML.it L'avatar di _debo
    Registrato dal
    Mar 2012
    residenza
    London, UK
    Messaggi
    858
    Ok l'ho formattato per i fatti miei ma non capisco, parli della una funzione ssh2_exec ma io nel codice che hai postato non la trovo. Sono cieco o te la sei dimenticata?

  7. #7
    Nel secondo codice c'è la funzione exec.phpselib lavora così

  8. #8
    Utente di HTML.it L'avatar di _debo
    Registrato dal
    Mar 2012
    residenza
    London, UK
    Messaggi
    858
    Phpseclib è una cosa, la funzione exec del tuo codice un altra, ed ssh2_exec un altra ancora.
    Mi sto perdendo per strada se devo essere sincero.
    Da dove hai presto questa phpselib (mi accorgo solo ora che non c'è la c nel nome)?

  9. #9

  10. #10
    Utente di HTML.it L'avatar di _debo
    Registrato dal
    Mar 2012
    residenza
    London, UK
    Messaggi
    858
    Avevo ragione io allora la "C" te l'eri persa per strada tu :-)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.