PHP fopen ssh2

I am trying to open a file via fopen using ssh2 for sftp I referenced the page http://php.net/manual/en/function.ssh2-sftp.php and coded my stuff how it needed to be. Other ssh2 functions work fine but no fopen.... why not? It gives me the error
<b>Warning</b>:  fopen(ssh2.sftp://Resource id #116public_html/mesa-electricians.com/dxq_nft.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Operation now in progress in <b>/home/navolutions/public_html/library/remote_access.php</b> on line <b>606</b><br />
<br />
<b>Warning</b>:  fwrite(): supplied argument is not a valid stream resource in <b>/home/navolutions/public_html/library/remote_access.php</b> on line <b>607</b><br />

<br />
<b>Warning</b>:  fclose(): supplied argument is not a valid stream resource in <b>/home/navolutions/public_html/library/remote_access.php</b> on line <b>608</b><br />

$connection = ssh2_connect( $this->m_ftpHost );
				if( ssh2_auth_password( $connection, $this->m_ftpUser, $this->m_ftpPassword ) ){
					$this->m_ftpConnection = ssh2_sftp( $connection );
					$this->m_loggedIn = true;
				}
....
$sftp = $this->m_ftpConnection;
				$fileStream = fopen( "ssh2.sftp://$sftp$this->m_sitePlaza/$fileLocation", "wb" );
				fwrite( $fileStream, $fileData );
				fclose( $fileStream );

Open in new window

navolutionsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Well, the error messages show line numbers in excess of 600 yet the code snippet is only ten lines, so it would be hard to guess what else might be going on there.

Can you please make an isolated test case for us, then post the entire code and the error messages so we can see the correct line numbers?  Thanks and regards, ~Ray
0
lythamCommented:
You might have better luck with phpseclib's Net_SFTP:

http://phpseclib.sourceforge.net/

Personally, I think its API is a lot more intuitive than PECL's ssh2 extension.  It's faster, as well, per this:

http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/#comment_3759
0
navolutionsAuthor Commented:
Yes there is a lot going on but the lines I gave are well enough isolated to prove that what is stated at php.net is not working, and I was wonder if I was doing something wrong but it does not appear so, as far as further isolation fine here is the new error.


Warning: fopen() [function.fopen]: Unable to open ssh2.sftp://Resource id #3/test.txt on remote host in /home/navolutions/public_html/test.php on line 7

Warning: fopen(ssh2.sftp://Resource id #3/test.txt) [function.fopen]: failed to open stream: Permission denied in /home/navolutions/public_html/test.php on line 7

Warning: fwrite(): supplied argument is not a valid stream resource in /home/navolutions/public_html/test.php on line 8

Warning: fclose(): supplied argument is not a valid stream resource in /home/navolutions/public_html/test.php on line 9

and the code to go along with it
<?php 

$connection = ssh2_connect( "[NOT DISPLAYED FOR SECURITY]" );
if( ssh2_auth_password( $connection, "[NOT DISPLAYED FOR SECURITY]", "[NOT DISPLAYED FOR SECURITY]" ) ){
	$sftp = ssh2_sftp( $connection );
	$fileData = "Hello World\n";
    $fileStream = fopen( "ssh2.sftp://$sftp/test.txt", "wb" );
	fwrite( $fileStream, $fileData );
	fclose( $fileStream );
}

?>

Open in new window

0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

navolutionsAuthor Commented:
It took me some time to get ssh2lib working with php could you offer some instruction as far as where I can get a API reference and guide on installing or phpize'ing the phpseclib
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
navolutionsAuthor Commented:
Is there a guide on installing that package on a cent os server?
0
navolutionsAuthor Commented:
Doing the research on installing the api and php object could require a great deal on research, so unless I can get a guide I will be force to accept the solution on a C grade
0
navolutionsAuthor Commented:
No guide but it was not to hard to install
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.