Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Vinicius de Lima

Problema com ssh2_connect

Recommended Posts

Pessoal,

 

Estou tentando executar o seguinte script PHP:

 

<?phpclass SFTPConnection{	private $connection;	private $sftp;	public function __construct($host, $port=22)	{		$this->connection = ssh2_connect($host, $port);		if (! $this->connection)			throw new Exception("Could not connect to $host on port $port.");	}	public function login($username, $password)	{		if (! @ssh2_auth_password($this->connection, $username, $password))			throw new Exception("Could not authenticate with username $username " .								"and password $password.");		$this->sftp = @ssh2_sftp($this->connection);		if (! $this->sftp)			throw new Exception("Could not initialize SFTP subsystem.");	}	public function uploadFile($local_file, $remote_file)	{		$sftp = $this->sftp;		$stream = @fopen("ssh2.sftp://$sftp$remote_file", 'w');		if (! $stream)			throw new Exception("Could not open file: $remote_file");		$data_to_send = @file_get_contents($local_file);		if ($data_to_send === false)			throw new Exception("Could not open local file: $local_file.");		if (@fwrite($stream, $data_to_send) === false)			throw new Exception("Could not send data from file: $local_file.");		@fclose($stream);	}}try{	$sftp = new SFTPConnection("201.63.164.17", 22);	//$sftp->login("root", "root");	//$sftp->uploadFile("/tmp/to_be_sent", "/tmp/to_be_received");}catch (Exception $e){	echo $e->getMessage() . "\n";}?>

Está dando este erro:

 

Fatal error: Call to undefined function ssh2_connect() in C:\Arquivos de programas\Apache Software Foundation\Apache2.2\htdocs\moodle\dmdweb\teste.php on line 10

 

Estou usando PHP 1.5.6 e Apache 2.2.3.

 

Consigo fazer esse acesso usando o putty.

 

Vinicius.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pessoal,Fiz o download da dll para a versão 1.5.6. do php e coloquei na pasta ext/.Agora quando tento restartar o apache ele dá o seguinte erro:PHP Warning: PHP Startup: Unable to load dynamic library php_ssh2Vinicius.

Pessoal,Estou tentando executar o seguinte script PHP:

<?phpclass SFTPConnection{	private $connection;	private $sftp;	public function __construct($host, $port=22)	{		$this->connection = ssh2_connect($host, $port);		if (! $this->connection)			throw new Exception("Could not connect to $host on port $port.");	}	public function login($username, $password)	{		if (! @ssh2_auth_password($this->connection, $username, $password))			throw new Exception("Could not authenticate with username $username " .								"and password $password.");		$this->sftp = @ssh2_sftp($this->connection);		if (! $this->sftp)			throw new Exception("Could not initialize SFTP subsystem.");	}	public function uploadFile($local_file, $remote_file)	{		$sftp = $this->sftp;		$stream = @fopen("ssh2.sftp://$sftp$remote_file", 'w');		if (! $stream)			throw new Exception("Could not open file: $remote_file");		$data_to_send = @file_get_contents($local_file);		if ($data_to_send === false)			throw new Exception("Could not open local file: $local_file.");		if (@fwrite($stream, $data_to_send) === false)			throw new Exception("Could not send data from file: $local_file.");		@fclose($stream);	}}try{	$sftp = new SFTPConnection("201.63.164.17", 22);	//$sftp->login("root", "root");	//$sftp->uploadFile("/tmp/to_be_sent", "/tmp/to_be_received");}catch (Exception $e){	echo $e->getMessage() . "\n";}?>
Está dando este erro:Fatal error: Call to undefined function ssh2_connect() in C:\Arquivos de programas\Apache Software Foundation\Apache2.2\htdocs\moodle\dmdweb\teste.php on line 10Estou usando PHP 1.5.6 e Apache 2.2.3.Consigo fazer esse acesso usando o putty.Vinicius.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.