Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net::SFTP::Foreign error on ->put() call

Status
Not open for further replies.

ajdavis

Programmer
Jun 17, 2005
14
US
I changed to Net::SFTP::Foreign because of issues with Net::SFTP. I'm getting an error on my ::Foreign ->put() call. My code is able to connect, change directories, and get a directory listing, but when I do the put, it errors out.
Couldn't setstat remote file (fsetstat): The requested operation cannot be performed because there is a file transfer in progress.
I am the only one ftp-ing to that directory and all I get on the remote server is a file of size 0. I can run sftp from the command line with the same user, password, remote directory, and file name and it works fine. Does anyone have any suggestions?

I've stripped my code down to just this:
Code:
#!/usr/bin/perl -X

use Net::SFTP::Foreign;
use strict;

my $host = "host";
my $username = "user";
my $password = "passwd";
my $directory = "dir";
$Net::SFTP::Foreign::debug = 1;

my $sftp = Net::SFTP::Foreign->new( "$username\@$host", password => $password );

$sftp->setcwd( "$directory" );

my @files = $sftp->ls();

foreach my $f ( @files ) 
{
	foreach my $file_ref ( @{$f} ) 
	{
		print "Found file: " . $file_ref->{'filename'} . "\n";
	}
}

$sftp->put( "test_file.txt" => "test_file.txt" );

if ( $sftp->error )
{
	print "Put error: " . $sftp->error . "\n";
	print "Put status: " . $sftp->status . "\n";
}

Here's the output with debugging turned on:
=> perl test2.pl
# queueing msg len: 5, code:1, id:3 ... [1]
# waiting for message... [1]
# got it!, len:5, code:2, id:3, status: -
# queueing msg len: 15, code:16, id:0 ... [1]
# waiting for message... [1]
# got it!, len:63, code:104, id:0, status: -
# queueing msg len: 18, code:11, id:1 ... [1]
# waiting for message... [1]
# got it!, len:10, code:102, id:1, status: -
# queueing msg len: 10, code:12, id:2 ... [1]
# waiting for message... [1]
# got it!, len:665, code:104, id:2, status: -
# queueing msg len: 10, code:12, id:3 ... [1]
# waiting for message... [1]
# got it!, len:17, code:101, id:3, status: 1
# queueing msg len: 10, code:4, id:4 ... [1]
# waiting for message... [1]
# got it!, len:40, code:101, id:4, status: 0
Found file: .
Found file: ..
Found file: PL_20080313
Found file: ae50.sh
# queueing msg len: 42, code:3, id:5 ... [1]
# waiting for message... [1]
# got it!, len:10, code:102, id:5, status: -
# queueing msg len: 18, code:10, id:6 ... [1]
# waiting for message... [1]
# got it!, len:106, code:101, id:6, status: 3
# queueing msg len: 10, code:4, id:7 ... [1]
# waiting for message... [1]
# got it!, len:40, code:101, id:7, status: 0
Put error: Couldn't setstat remote file (fsetstat): The requested operation cannot be performed because there is a file transfer in progress.
Put status: The requested operation cannot be performed because there is a file transfer in progress.

 
Hi, I am the author of Net::SFTP::Foreign.

It seems that the server you are connecting to, doesn't like the way Net::SFTP::Foreign transfers files. Could you provide me with more details about the server in order to set a workaround in place (OS, SSH sofware vendor and versions)?

Also, set the debug level to 9 to get a dump of all the packets exchanged and send it to me.

In the meantime, as a workaround, search inside the "put" method definition on the module, for the lines...

# open does not set the attributes for existant files so we do it again:
$sftp->fsetstat($rfh, $attrs)
or return undef;

and delete them (they are at line number 1610 aprox. in Net/SFTP/Foreign.pm).

Finally, if you find any other bug on the module, please, send me a bug report by email (it appears on the module docs) or using the CPAN RT. And BTW, to get help for anything related to Perl, is the way to go!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top