Problems with Win32::Internet FTP->put

A

AJ

I can't seem to get a file to "put" onto an FTP server. I can "get"
files without issue. I don't receive any errors from my last print
statement below (I just get "transferred failed []"). I have gone to
specifying a test file by name instead of a variable, still no luck.

Anyone have any insights?

Here is the code:

use Win32::Internet;
$inet = new Win32::Internet();
$inet->FTP($MYFTPSRV, "ftpsrv", "ftpuser", "ftppassword");
if ($MYFTPSRV->Cd("/FromHost")) {
print "cd sucess\n";
if ($MYFTPSRV->Put("c:/temp/testfile.tst")){
print "put success\n";
} else { print "transfer failed [$@]\n";
}
}
$inet->Close($MYFTPSRV);

Thanks,

--AJ
 
P

Paul Lalli

AJ said:
I can't seem to get a file to "put" onto an FTP server. I can "get"
files without issue. I don't receive any errors from my last print
statement below (I just get "transferred failed []"). I have gone to
specifying a test file by name instead of a variable, still no luck.

Anyone have any insights?

Here is the code:

use Win32::Internet;
$inet = new Win32::Internet();
$inet->FTP($MYFTPSRV, "ftpsrv", "ftpuser", "ftppassword");
if ($MYFTPSRV->Cd("/FromHost")) {
print "cd sucess\n";
if ($MYFTPSRV->Put("c:/temp/testfile.tst")){
print "put success\n";
} else { print "transfer failed [$@]\n";
}
}
$inet->Close($MYFTPSRV);

I have no idea what's making you think $@ would contain an error
message. There's no mention of $@ in the documentation. Please search
the docs for the Error() and GetResponse() methods. Once you've
determined the reason for the failure, if you can't figure out what's
wrong, post here again, with your updated script and error output.

Paul Lalli
 
A

AJ

Paul said:
AJ said:
I can't seem to get a file to "put" onto an FTP server. I can "get"
files without issue. I don't receive any errors from my last print
statement below (I just get "transferred failed []"). I have gone to
specifying a test file by name instead of a variable, still no luck.

Anyone have any insights?
....

I have no idea what's making you think $@ would contain an error
message. There's no mention of $@ in the documentation. Please search
the docs for the Error() and GetResponse() methods. Once you've
determined the reason for the failure, if you can't figure out what's
wrong, post here again, with your updated script and error output.

Paul Lalli

Paul, Thanks for your reply. I did find the GetResponse gives me back
the last response from the remote server (in this case it returns "250
CWD command successful." response to the change directory command). Not
necessarily helpful... Updated code is below. Following this is the
debug output from running "perl -d testftp.pl".

use Win32::Internet;

$inet = new Win32::Internet();

$inet->FTP($MYFTPSRV, "ftpsrv", "ftpuser", "ftppassword");

if ($MYFTPSRV->Cd("/FromHost")) {

print "cd sucess\n";

if ($MYFTPSRV->Put("c:/temp/testfile.tst")){

print "put success\n";

} else {
$failed = $MYFTPSRV->GetResponse();
print "transfer failed [$failed]\n";
}
}
$inet->Close($MYFTPSRV);

The following is output from perl -d testftp.pl:

main::(testftp.pl:8): if
($MYFTPSRV->Put("c:/temp/testfile.tst")){

DB<1> s
Win32::Internet::put(C:/Perl/site/lib/Win32/Internet.pm:1085):
1085: my($self, $local, $remote, $context) = @_;
DB<1> s
Win32::Internet::put(C:/Perl/site/lib/Win32/Internet.pm:1086):
1086: return undef unless ref($self);
DB<1> s
Win32::Internet::put(C:/Perl/site/lib/Win32/Internet.pm:1088):
1088: if($self->{'Type'} ne "FTP") {
DB<1> s
Win32::Internet::put(C:/Perl/site/lib/Win32/Internet.pm:1092):
1092: my $mode = ($self->{'Mode'} eq "asc" ? 1 : 2);
DB<1> s
Win32::Internet::put(C:/Perl/site/lib/Win32/Internet.pm:1094):
1094: $context = 0 unless defined($context);
DB<1> s
Win32::Internet::put(C:/Perl/site/lib/Win32/Internet.pm:1096):
1096: my $retval = FtpPutFile($self->{'handle'}, $local, $remote,
$mode, $context);
DB<1> s
Win32::Internet::put(C:/Perl/site/lib/Win32/Internet.pm:1097):
1097: $self->{'Error'} = "Can't put file." unless
defined($retval);
DB<1> s
Win32::Internet::put(C:/Perl/site/lib/Win32/Internet.pm:1098):
1098: return $retval;
DB<1> s
 
J

J. Gleixner

AJ said:
Paul said:
AJ said:
I can't seem to get a file to "put" onto an FTP server. I can "get"
files without issue. I don't receive any errors from my last print
statement below (I just get "transferred failed []"). I have gone to
specifying a test file by name instead of a variable, still no luck.

Anyone have any insights?
...
I have no idea what's making you think $@ would contain an error
message. There's no mention of $@ in the documentation. Please search
the docs for the Error() and GetResponse() methods. Once you've
determined the reason for the failure, if you can't figure out what's
wrong, post here again, with your updated script and error output.

Paul Lalli

Paul, Thanks for your reply. I did find the GetResponse gives me back
the last response from the remote server (in this case it returns "250
CWD command successful." response to the change directory command). Not
necessarily helpful... Updated code is below. Following this is the
debug output from running "perl -d testftp.pl".

use Win32::Internet;

$inet = new Win32::Internet();

$inet->FTP($MYFTPSRV, "ftpsrv", "ftpuser", "ftppassword");

if ($MYFTPSRV->Cd("/FromHost")) {

print "cd sucess\n";

if ($MYFTPSRV->Put("c:/temp/testfile.tst")){

print "put success\n";

} else {
$failed = $MYFTPSRV->GetResponse();
print "transfer failed [$failed]\n";
}
}
$inet->Close($MYFTPSRV);

Taking a quick look through the test.pl script, that comes with the
package
(http://search.cpan.org/src/GSAR/libwin32-0.191/Internet/test.pl), shows:

print " Trying 'put test.pl'...\n";
$result = $FTP->Put("test.pl","test.pl");
$err = $FTP->Error();
print "*** Error: $err\n" if ! $result;

Maybe Error() will'll help you determine the issue.
 
M

Matt Garrish

AJ said:
Updated code is below. Following this is the
debug output from running "perl -d testftp.pl".
use Win32::Internet;

$inet = new Win32::Internet();

$inet->FTP($MYFTPSRV, "ftpsrv", "ftpuser", "ftppassword");

If you're using MS proxy server:

http://support.microsoft.com/kb/233285/EN-US/

Other thoughts: Have you tried specifying the remote file name? Since
only the local is specified, you're also trying to write to
'c:/temp/testfile.tst' on the remote server. Is that really what you're
trying to do?

You might also want to try setting pasv before opening the connection.

Matt
 
A

AJ

Matt said:
If you're using MS proxy server:

http://support.microsoft.com/kb/233285/EN-US/

Other thoughts: Have you tried specifying the remote file name? Since
only the local is specified, you're also trying to write to
'c:/temp/testfile.tst' on the remote server. Is that really what you're
trying to do?

You might also want to try setting pasv before opening the connection.

Matt

Matt,

Good insight, that was it. This thing has been plaging me for far to
lang... Thank you for your help and thanks to eveyone elese for taking
the time to give me your thoughts.

--AJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top