I can't be sure that this is right, but I think it is and I think you
should check it out.
FTP supports two different socket connections -- Active and Passive. Active
connections are established on port 21 and retained on that port for the
duration of the connection. Passive connections are initiated on Port 21
and then the ftp server immediately transfers it to a higher port for the
exclusive use of that particular client. It is my understanding that
proxies often take a request for an active connection and pass it along as
a passive one. You then have the ability to log into the server, but the
next time you try to connect on port 21, the server wants new login
information. To test this, try something like a GET or an MGET instead of
your STOR.
For a better explanation of this (I am by no means an expert and I know I
have mangled it) check out RFC 1579. It explains the problem in great
detail and it is available at
http://info.internet.isi.edu/in-notes/rfc/files/rfc1579.txt.
Ben
At 06:04 PM 2/7/01 -0500, Michael Snead wrote:
>Help!!
>
>I'm trying to FTP a file up to the web through a Socks5 firewall from within
>a Perl script. I've seen other postings on the web about this, but there
>haven't been any answers. Hopefully someone out there will respond.
>
>I've tried this 2 ways, both with problems:
>
>#1.
>
>##!/usr/bin/perl -w
>$|++;
>
>use Net::SOCKS;
>
># Open the connection.
>$sock = undef(); #Clear it first.
>my $sock = new Net::SOCKS(socks_addr => '192.168.1.11',
> socks_port => 4080,
> protocol_version => 5);
>
>$f = undef(); #Clear it first.
>my $f=$sock->connect(peer_addr=>'ftp.hostname.com', peer_port=>21);
>print "connect status: ",
> Net::SOCKS::status_message($sock->param('status_num')), "\n";
>if ($sock->param('status_num') == SOCKS_OKAY) {
> print $f ("USER xxxxxxx\n");
> print $f ("PASS *******\n");
> print $f ("CWD /directory\n");
> print $f ("TYPE I\n");
> print $f ('STOR file.txt' . "\n");
> print $f ("QUIT\n");
> while (<$f>) { print }
> $sock->close();
> print "Conection closed";
>}
>
>This works for everything EXCEPT the STOR. (Which is what I'm trying to
>do.) Below is what happens:
>
>connect status: okay
>220 hostname.com X2 WS_FTP Server 2.0.0
>331 Password required
>230-user logged in
>230-Welcome to Hostname.
>230 user logged in
>250 CWD successful
>200 Type set to IMAGE.
>425 Can't open data connection.
>221-Good-Bye
>221-Goodbye.
>221 Good-Bye
>Conection closed
>
>It also will not do the LIST command. Could someone explain this to me?
>
>2. I've tried using Net::FTP both with it's proxy support and by attempting
>to open a socks connection and FTPing through it, both of which have failed.
>
>If it is possible to FTP through a socks connection, could someone tell me
>how? If not, then could someone tell me how to get the STOR to work in the
>example above?
>
>Thanks in advance,
>Michael Snead
>
>_______________________________________________
>Perl-Win32-Users mailing list
>[EMAIL PROTECTED]
>http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users