Have a simple script to FTP all files in one dir to a Solaris box.
Script runs fine when invoked from command line. However, when invoked
from browser (simple html form with one button that calls the .pl
script), only some files get FTPd. The process seems to stall, then
the browser times out.

Running Apache 2.2 on Windows 2003 SP2, perl 5.8.8, ftp-ing to Solaris
9 box.

#!c:/Perl/bin/perl.exe
use CGI qw/:standard/;
use Net::FTP;

$| = 1;

$sourcedir = "d:\\sourcefiles";
$ftpdir = "/destination";

print header;
print start_html('FTP');
$time = `time /T`;
chomp($time);
print h4("ftp beginning - $time");

### get list of files in source directory
opendir(DIR, $sourcedir);
@files = readdir(DIR);
closedir(DIR);

### open FTP connection
$ftp = Net::FTP->new("10.0.0.1", Debug => 1, BlockSize => 4096);
$ftp->login("user", "pass");
$ftp->binary();
$ftp->cwd("$ftpdir");

foreach $file (@files) {
        if ($file !~ /^\./) {
                if ($file =~ /\.jpg$|\.xml$/) {
                        $ftp->put("$sourcedir\\$file");
                        $time = `time /T`;
                        chomp($time);
                        print p("$file ftp'd");
                }
        }
}

$ftp->quit;

$time = `time /T`;
chomp($time);

print h1("All done at $time!"), end_html;


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to