--- dir2sap.pl 2003/03/20 10:13:13 1.1 +++ dir2sap.pl 2003/03/24 16:35:39 1.2 @@ -7,8 +7,8 @@ use SAP::Rfc; use Data::Dumper; use XML::Simple; -use AnyDBM_File; -use Fcntl; # for O_* values +use Fcntl; # For O_RDWR +use NDBM_File; my $config_file; @@ -27,7 +27,7 @@ # open log and redirect die to it... open(LOG,">> $log") || warn "open log $log: $!"; -local $SIG{__DIE__} = sub { print LOG scalar localtime $_[0] ; die $_[0] }; +local $SIG{__DIE__} = sub { print LOG scalar localtime," ",$_[0] ; die $_[0] }; # directory in which are files my $indir = $config->{indir} || die "config: no defined"; @@ -36,7 +36,7 @@ my $dbm = $config->{dbm} || die "config: no defined"; my %dbmhash; -tie %dbmhash, "AnyDBM_File", $dbm, O_RDWR || die "tie: can't tie to '$dbm': $!"; +tie %dbmhash, "NDBM_File", $dbm, O_RDWR, 0666 || die "tie: can't tie to '$dbm': $!"; my $rfc = new SAP::Rfc( ASHOST => $config->{sap}->{ashost}, @@ -50,6 +50,25 @@ $rfc->is_connected || die "FATAL: SAP not connected"; +print STDERR "Using '$indir' as input directory...\n"; + +opendir(DIR, $indir) || die "can't opendir $indir: $!"; +my @files = grep { !/^\./ && -f "$indir/$_" } readdir(DIR); +closedir DIR; + +print LOG scalar localtime," Found ",$#files+1," files in directory...\n"; + +foreach my $file (@files) { + if ($dbmhash{$file}) { + print LOG scalar localtime," New file '$file', processing...\n"; + $dbmhash{$file}++; + } else { + print STDERR scalar localtime," Skipping file '$file'\n"; + } +} + +exit 1; # fix + my $it = $rfc->discover($config->{sap}->{discover}) || die "FATAL: SAP discover: $!"; foreach my $p ($config->{sap}->{params}) {