Macworld Forums: perl ftp - Macworld Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

perl ftp

#1 User is offline   shoes Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 17-October 06

Posted 17 October 2006 - 09:15 PM

Uh oh... Unix user on a Mac... watch out!
I often upload to my webpage from my Mac. I used to do the ftp manually, and 'mput ' worked fine.

I wanted to automate the process so I wrote a script (ftpangela.pl) in perl (v5.8.1-RC3 built for darwin-thread-multi-2level
(with 1 registered patch...)) under OS X (10.3.9). It works fine for a while and then it hangs up in the middle of the transfer. Here is the dialog:

...
Net::FTP=GLOB(0x80fedc)>>> ALLO 45073
Net::FTP=GLOB(0x80fedc)<<< 202 No storage allocation necessary.
Net::FTP=GLOB(0x80fedc)>>> PORT 192,168,1,100,193,20
Net::FTP=GLOB(0x80fedc)<<< 200 PORT command successful
Net::FTP=GLOB(0x80fedc)>>> STOR B5.jpg
Net::FTP=GLOB(0x80fedc)<<< 150 Opening BINARY mode data connection for B5.jpg
Net::FTP=GLOB(0x80fedc)<<< 226 Transfer complete.
Net::FTP=GLOB(0x80fedc)>>> ALLO 4756
Net::FTP=GLOB(0x80fedc)<<< 202 No storage allocation necessary.
Net::FTP=GLOB(0x80fedc)>>> PORT 192,168,1,100,193,21
Net::FTP=GLOB(0x80fedc)<<< 200 PORT command successful
Net::FTP=GLOB(0x80fedc)>>> STOR B5t.jpg
Net::FTP=GLOB(0x80fedc): Timeout at ftpangela.pl line 41
Warning: something's wrong at ftpangela.pl line 41.
Net::FTP=GLOB(0x80fedc)>>> ALLO 40529
Net::FTP=GLOB(0x80fedc): Timeout at ftpangela.pl line 41
Net::FTP=GLOB(0x80fedc)>>> PORT 192,168,1,100,193,22
Net::FTP=GLOB(0x80fedc)<<< 421 No Transfer Timeout (300 seconds): closing control connection.
No Transfer Timeout (300 seconds): closing control connection.
Net::FTP=GLOB(0x80fedc)>>> ALLO 4496
Net::FTP: Unexpected EOF on command channel at ftpangela.pl line 41
Connection closed at ftpangela.pl line 41.

Is this a ftp problem? Perl problem? OS X problem? I'm transferring about 400 files; it dies randomly in the middle.


Here is my crude perl script (note, the line #s reported above no longer match the script below):

#! /usr/bin/perl -w

# this version intermittently stops with a timeout in the ftp put.
# see "perlftpfault.txt" for the error message.
# running the same commands at the command prompt instead of within
# perl runs fine. What is the issue? Too many files?
# the put doesn't fail with a warning; it just times out so Perl
# reports the warning.


use Net::FTP;


$ftp = Net::FTP->new('ftp.xxx.com', Debug => 1);
$ftp->login('xxx','xxx');

$ftp-> binary();

chdir("/Users/webpage/html");

foreach my $file (glob('
'))
{
$ftp->put($file) or warn $ftp->message;
sleep(2);
}
$ftp->cwd("images");
chdir("images");
foreach my $file (glob(''))
{
$ftp->put($file) or warn $ftp->message;
sleep(2);
}

$ftp->cwd("slices");
chdir("slices");

foreach my $file (glob('
'))
{
$ftp->put($file) or warn $ftp->message;
sleep(2);
}
$ftp->close();
$ftp->quit;

Any suggestions will be appreciated. The two second delays didn't help.
0

#2 User is offline   shoes Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 17-October 06

Posted 18 October 2006 - 08:53 PM

I tried uploading to a different ISP... same problem. That narrows it down to OS X, perl, or ftp... Next I'll try perl and ftp in Linux.
0

#3 User is offline   maczan1205 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 403
  • Joined: 13-August 01

Posted 18 October 2006 - 11:07 PM

Why not try transmit, it easy to use and you can edit most scripts (html and php - not sure about perl scripts) by simply clicking on the script.
You can download a demo and try it out Transmit 3 Info
0

#4 User is offline   shoes Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 17-October 06

Posted 20 October 2006 - 09:12 PM

Thanks zan,
That looks too easy. Why write a script when the Mac will do it for you?! Good stuff!
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users