Subject: | SFTP: Wrong flags are used - impossible to create files |
I'm using Net::SSH2::SFTP with the following code:
use Net::SSH2;
my $s2 = Net::SSH2->new();
$s2->connect('hostname:22') or die "connect failed: ($!) (", $s2->error,
")\n";
if ($s2->auth_publickey ( "username", ".ssh/my_id_dsa.pub",
".ssh/my_id_dsa", "passphrase" )) {
my $sftp = $s2->sftp() or die "Calling sftp failed: ($!) (",
$s2->error, ") (", $sftp->error, ")\n";
my $file = $sftp->open("blabla", O_WRONLY, 0666) or die "open failed:
($!) (", $s2->error, ") (", $sftp->error, ")\n";
}
$s2->disconnect();
So, I want to create a file on the remote side, that definitely does not
exist. And: permissions are ok.
Executing the script dies with the following error:
open failed: (Resource temporarily unavailable)
(-31LIBSSH2_ERROR_SFTP_PROTOCOLFailed opening remote file)
(2SSH_FX_NO_SUCH_FILE)
Somehow right, as the file really does not exist, but if a truss/strace
the ssh-daemon on the remote host, I see the following open-call:
open("blabla", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
Somehow confusing as I wanted to create/open the file with O_WRONLY (not
O_RDONLY). No matter what flags I'm using (O_WRONLY|O_CREAT|O_EXCL,
...), the system call on remote side is always O_RDONLY|O_LARGEFILE.
My environment:
uname -a: SunOS 5.10 Generic_118833-03 sun4u sparc SUNW,Sun-Fire-880 Solaris
and uname -a: Linux 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005
i686 i686 i386 GNU/Linux
perl -v: This is perl, v5.8.5 built for sun4-solaris
and perl -v: This is perl, v5.8.5 built for i386-linux-thread-multi
Net::SSH2: Net-SSH2-0.08 (Net-SSH2-0.07 does not work either)
libssh2: libssh2-0.14 (libssh2-0.12 does not work either)