witam wykorzystuję w PHP lobkę do ssh: http://phpseclib.sourceforge.net/
stworzyłem sobie klasę:
include_once 'Net/SSH2.php';
class SSH{
private $host = "localhost";
private $login = "xgen";
private $password = "asdzxcasdzxc123";
private $ssh;
public function __construct(){
$this->ssh = new Net_SSH2($this->host);
if (!$this->ssh->login($this->login, $this->password)) {
echo "Login Failed";
}
}
public function getScreenList(){
echo $this->ssh->exec("screen -list");
}
public function send(){
echo $this->ssh->exec('pwd');
echo $this->ssh->exec('ls -la');
}
}
oraz index.php:
include_once '../sshUtils.php';
$sssh = new SSH();
$sssh->send();
gdy libka, obiekt SSH i index.php są w tym samym miejscu, wszystko śmiag jak powinno. jednak gdy przeniose index.php do np. jakiegoś podfolderu, skrypt rzyga takimi błędami:
Warning: include_once(Math/BigInteger.php): failed to open stream: No such file or directory in /home/xgen/html/Projekty/SSH test/Net/SSH2.php on line 943
Warning: include_once(): Failed opening 'Math/BigInteger.php' for inclusion (include_path='.:/usr/share/php') in /home/xgen/html/Projekty/SSH test/Net/SSH2.php on line 943
Warning: include_once(Crypt/Random.php): failed to open stream: No such file or directory in /home/xgen/html/Projekty/SSH test/Net/SSH2.php on line 947
Warning: include_once(): Failed opening 'Crypt/Random.php' for inclusion (include_path='.:/usr/share/php') in /home/xgen/html/Projekty/SSH test/Net/SSH2.php on line 947
Warning: include_once(Crypt/Hash.php): failed to open stream: No such file or directory in /home/xgen/html/Projekty/SSH test/Net/SSH2.php on line 951
Warning: include_once(): Failed opening 'Crypt/Hash.php' for inclusion (include_path='.:/usr/share/php') in /home/xgen/html/Projekty/SSH test/Net/SSH2.php on line 951
Warning: include_once(Crypt/Base.php): failed to open stream: No such file or directory in /home/xgen/html/Projekty/SSH test/Net/SSH2.php on line 956
Warning: include_once(): Failed opening 'Crypt/Base.php' for inclusion (include_path='.:/usr/share/php') in /home/xgen/html/Projekty/SSH test/Net/SSH2.php on line 956
Fatal error: Uncaught Error: Call to undefined function phpseclib_resolve_include_path() in /home/xgen/html/Projekty/SSH test/Net/SSH2.php:1363 Stack trace: #0 /home/xgen/html/Projekty/SSH test/Net/SSH2.php(1255): Net_SSH2->_key_exchange() #1 /home/xgen/html/Projekty/SSH test/Net/SSH2.php(2210): Net_SSH2->_connect() #2 /home/xgen/html/Projekty/SSH test/Net/SSH2.php(2194): Net_SSH2->_login('xgen', 'asdzxcasdzxc123') #3 /home/xgen/html/Projekty/SSH test/sshUtils.php(19): Net_SSH2->login('xgen', 'asdzxcasdzxc123') #4 /home/xgen/html/Projekty/SSH test/sshUtils.php(37): SSH->__construct() #5 /home/xgen/html/Projekty/SSH test/x/index.php(6): include_once('/home/xgen/html...') #6 {main} thrown in /home/xgen/html/Projekty/SSH test/Net/SSH2.php on line 1363
na stronie libki była taka linijka pdoobno potrzebna do dodania:
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
jednak ona nic nie zmieniała (zapewne muszę tam poustawiać informacje, ale nie wiem nawed co przy tej funkcji zrobić