HI all,

This is my ftp client program which is using Net::FTP module. And I have one webpage from where i am giving the inputs to the perl program.
Inputs are
1. ftp host
2. user name
3. password
4.file name to put or get from ftpserver
5 no. of times i want to repeat the operation.

MY PROBLEM IS
1. this progrm is working fine when I am doing a PUT operation.
BUT WHEN I AM DOING GET OPERATION THE ERROR MESSEGE "ABORTED, DATA CONNECTION CLOSED" IS COMING.The file i requested is present on the ftp server and also the path is correct

When I have captured the packets in ethereal One strange thing i have noticed
1. AFTER FTP HOST SENDS "OPENING ASCII MODE DATA TRANSFER.." PACKET, MY LOCAL PC IS SENDIG "request yoy" and one "request oABOR" packet to the ftp server. and after that ftp connection is closed.

but i don't know the reason why my PC is sending those 2 packets(yyy and oABOR)

when i removed the code for Getting data from the web page and all the necessary variables are hardcoded. For ex.
$ftphost='192.168.100.2'; $user='munu'; $pass='munu'; $file='a.b'; $count =10;
THE CODE IS WORKING FINE FOR BOTH GET AND PUT

I have put the code below for your reference

#!/usr/bin/perl use CGI; use Net::FTP; ######################### my $q = CGI->new(); print $q->header("text/html"); print"\n"; ####################### #Code to get input from the web $buffer; my @pairs; my $pair; my %FORM; $buffer = $ENV{'QUERY_STRING'}; @pairs =split(/&/,$buffer); foreach $pair (@pairs) { (my $name,my $value)=split(/=/,$pair); $value =~ tr/+/ /; $value =~ s/%(..)/pack("C", hex($1))/eg; $FORM{$name} = $value; } ############################ $ftphost=$FORM{serverip};#ftp host $user=$FORM{user};#username $pass=$FORM{pass};#password $file=$FORM{file};#filename $count = $FORM{count};#no. of times to get the file or no. of ftp con +nections print $ftphost, $user, $pass, $file, $count; $!=1; $c=1; while ($count >= 1) { $ftp = Net::FTP->new($ftphost, Debug => 1,Hash=>1); ############################################## #or die "incorrect username or passwd"; is not printing anything. That +s why i have written in the following #manner. if(! $ftp->login($user,$pass)) { print "incorrect user name or password"; die; } ################################## #put is working fine but get is not working $ftp->put($file); ################################### print $ftp->message; ##in the messege it is telling "ABORTED SUCCESSFULLY" print $c++," success"; $count--; }

thanks
MUNU

Edited by Chady -- added code tags.


In reply to Problem with NET::FTP->GET functionality from the web by munu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.