Question Locked

Help understand Perl script(s)

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

need some help to understand what this Perl script do. The guy who made it is probably dead since it's so old, but we need it.

Can u guys help? :)

I've censored stuff.
If someone could remake this script over to another language used today, that would be great.

4 replies

by perlsomewhat

## .bat file:

@echo off
rem Script called from file_import.bat
rem Is called with default parameters
rem %1 %2 %3 %4 %5 %6
rem
rem perl edl400ba.pl "%area%" %area% %ip% slf %name003% >> \temp\edl400ba.log

rem If Perl is installed below ORACLE_HOME must variable PERL5LIB be blanked
set PERL5LIB=
set PATH=C:\strawberry\perl\bin;%PATH%

perl edl400ba.pl "%area%" %2 %3 %4 %5 >> \temp\edl400ba.log

by perlsomewhat

use Net::FTP;

$catalog=$ARGV[0] ; # e.g. %area%
$sqluser=$ARGV[1] ; # oracle connection string; user/user@user
#$sqluser="%area%" ;
$ftp_adr=$ARGV[2] ; # ftp server, ip adress
$ftp_user=$ARGV[3];
$ftp_pwd=$ARGV[4] ;
$loggfile="$catalog/proc/ftplog.$$" ;
$programname="EDL400BA" ;

$local_dir="%area%";
$read_catalog=$katalog . "/%area%" ;

chdir $catalog . "/" . $local_dir || die "could not cwd to $katalog . "/" . $local_dir \n";

$ftp = Net::FTP->new($ftp_adr, Debug => 0) or die "Can't start ftp\n";
$ftp->login($ftp_user,$ftp_pwd) or die "Login error: $ftp_user/$ftp_pwd";

$filecount=0;
foreach $file ($ftp->ls) {
if ($file =~ /^e.*/ ) {
$ftp->get($file) or die "Can't get the file $file\n";
$filecount++;
$cmd = "perl $catalog/script/load_edl400ba.pl $catalog $sqluser $file";
if ( system($cmd) == 0 ) {
$ftp->delete($file) or print "Couldn't delete the file: $file\n";
}
else {die "Error loading file: $file - ending.\n"};
rename $catalog . "/" . $local_dir . "/" . $file, $read_catalog . "/" . $file;
}
}

$ftp->quit || print "Error closing ftp (ignored)\n";

print "$filecount file(s) grabbed from the server $ftp_adr\n";

by perlsomewhat

CATALOG=$1
USER=$2
FILE1=$3
GRNS_IN=$CATALOG /%area%
ORACLE_SID=egg;export $ORACLE_SID

# If the bad-file is found from f|r it shall be deleted
if test -r $CATALOG/bad/edl400ba.bad;
then rm $CATALOG/bad/edl400ba.bad;
fi;

# rows set to 64000 so that nothing is read in by accident
cd $CATALOG

sqlldr CONTROL=ctl/edl400ba.ctl, LOG=log/edl400ba, BAD=bad/edl400ba, DATA=$GRNS_IN/$FILe1, USERID=$USER, ERRORS=0,LOAD=99999, DISCARD=dsc/edl400ba ,DISCARDMAX=99999,ROWS=64000

# If the bad-filen has been created, an error message is given
if test -r $CATALOG/bad/edl400ba.bad;
then exit 9;
#else mv $GRNS_IN/$FILE1 $GRNS_OUT/$FILE1.read;
fi;

by perlsomewhat

@echo off
rem Script called from file_import.bat
rem Is called with default parameters
rem %1 %2 %3 %4 %5 %6
rem
rem perl edl400ba.pl "%area%" %area% %ip% slf %name003% >> \temp\edl400ba.log

rem If Perl is installed below ORACLE_HOME must variable PERL5LIB be blanked
set PERL5LIB=
set PATH=C:\strawberry\perl\bin;%PATH%

perl edl400ba.pl "%area%" %2 %3 %4 %5 >> \temp\edl400ba.log

This discussion is closed to new replies.