You are here: Re: SFTP problems « PHP « IT news, forums, messages
Re: SFTP problems

Posted by "M. Sokolewicz" on 06/19/05 19:37

Lowell Allen wrote:

> I need to use SFTP to send text files and binary files from one server
> to another, but I'm unable to use fopen on the remote server, and if I
> send with ssh2_scp_send the files are truncated. I'm assuming the
> libssh2-PECL/ssh2 installation isn't the problem because I'm able to
> connect using ssh2_auth_password, create a directory on the remote
> server with ssh2_sftp_mkdir, and copy files with ssh2_sftp_send and
> ssh2_sftp_recv (even though ssh2_sftp_send truncates files).
>
> When I try to use fopen, I get this error message:
>
> Warning: fopen(): Unable to open ssh2.sftp://Resource id
> #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt on
> remote host in /home/user/public_html/cms/sftp_test.php on line 79
>
> Warning: fopen(ssh2.sftp://Resource id
> #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt): failed
> to open stream: Resource temporarily unavailable in
> /home/user/public_html/cms/sftp_test.php on line 79
>
> Here's line 79 of sftp_test.php:
>
> $stream =
> fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/
> flamingo/".$filename, "wt")
>
> I've read "Secure Communications with PHP and SSH" in the February PHP
> Architect. That's what prompted me to try PECL/ssh2, but now I'm stuck.
> Anybody successfully using fopen with SFTP or anybody using
> ssh2_sftp_send without getting truncated files?
>

First of all, posting this once is enough. Second of all, I think the
problem here is actually a lot easier than it would look at first glance :)

I noticed the following error:
Warning: fopen(ssh2.sftp://Resource id #10/[...]): [...]

Now, what you see here is that you suddenly have a "ssh2.sftp://Resource
id #10". This is probably not the domain name you're trying to connect
to, now is it? :) That string typically appears only when you cast a
resource to a string (eg. a mysql-connection, a stream, or whatever).
So, looking at line 79, I would guess that $sftp isn't a string which
tells fopen where to find the file to open, but instead is a resource
which should not be there at all.

- tul

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация