[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] first file in a folder...



At 15.11 10/13/97, { brad brace } wrote:
>I'm trying to write a script that will:
>
>1) every 12 hours: select the first file in a folder (Mac 68K OS
>   ideally)... I have Mac-Cron installed... and...
>
>2) dialup my ISP and upload the file to several FTP sites (I have
>   Microphone-comm-software scripts that can dialup -- I can't seem to
>   make them select a specific file though...) (I have MacPerl installed.)
>
>3) then, either delete or move this first file from the folder, so that
>   the next numerically-named file will become the next 'first-one'
>
>4) and so on...

Here would be my solution:

#!perl -w
#both modules below available at http://pudge.net/macperl/
#require shareware FTP program Anarchie and OT/PPP 1.0
#or greater

use Mac::Apps::Anarchie;
use Mac::Comm::OT_PPP;

my $localdir   = 'HD:mydir';
my $remotedir  = '/export/home/mydir';
opendir(D,$localdir) || die $!;
my @files      = sort readdir(D);
closedir(D);
my $file       = shift @files;
my $localfile  = "$localdir:$file";
my $remotefile = "$remotedir/$file";

$ppp = Mac::Comm:OT_PPP;
$err = $ppp->PPPConnect($user,$pass,$number);
if ($err) {
   MacPerl::Answer("OT/PPP error: $err");
} else {
   $ftp = new Mac::Apps::Anarchie;
   $ftp->store($localfile,$remotefile,0,'host.com','user','pass');
}
unlink $localfile;  #delete file
exit;

--
Chris Nandor             pudge@pobox.com             http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==            MacPerl:  Programming for the Rest of Us            ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch