Hi All, Really need some help here. I am using PERL CGI application for uploading files through FTP and its not working. The message that it shows is "Can't open data connection". Only the file that i want to upload is created at the destination with zero bytes. Well when i do FTP using a client software, it works for that same remote machine and files are uploaded. This code works well when executed to connect another system in the same network and files are uploaded. The Code is:
sub fnSaveFile { my $sDriver = $vars{'driverfname'}; my $sXML = $vars{'xmlfname'}; #print $sDriver; if ($sDriver eq '' || $sXML eq '') { fnShowForm(); print "please provide information for the empty fie +lds to execute"; exit(); } my $sFile = "C:/MyCreationInPerl/$sDriver"; open(FILE,">$sFile") or die "Can not open file $sDriver"; $sReport1 = 'temp'; print FILE "some information"; close FILE; my $sFile = "C:/MyCreationInPerl/$sXML"; open(FILE,">$sFile") or die "cannot open file"; print FILE "some information"; close FILE; my $host = 'xx.xx.xx.xx'; my $ftp = Net::FTP->new($host, Timeout => 300, Debug=>1) or die "Cannot contact $host: $!"; my $output2 = $ftp->login('xxxx','xxxxxx') or die "Can't login ($host):" . $ftp->message; $ftp->pasv(); my $path1 = '/testdata/BatchValidation/driver/'; my $output = $ftp->cwd($path1) or die "cannot change dir +ectory $path1"; $ftp->ascii(); my $filenameDriver = "C:\\MyCreationInPerl\\$sDriver"; my $output1 = $ftp->put($filenameDriver) or die $ftp->message; print $output1; #my $path2 = '/testdata/BatchValidation/xml'; #my $output = $ftp->cwd($path2) or die "cannot change director +y $path2"; #$ftp->ascii(); #my $filenameXML = "C:\\MyCreationInPerl\\$sXML"; #my $output3 = $ftp->put($filenameXML) or die "cannot put $fil +enameXML to the destination"; ##print $output1; #Win32::MsgBox ("Files have been transfered"); $ftp->quit; fnShowFormForExecution(); }
Please someone help me!! Thanks !!

In reply to perl: FTP using cgi not working but FTP s/w works well by need_help21

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.