Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Forum » x-Forum » Question

Need assistance understanding Perl script - Quite urgant


can someone help me understand what this script does in, Perl? I've edited out all sensitive info. and such connections to DB.
The user who made this once, is probably dead by now, and we need it in a migration project.

Thanks in advance. :)

## .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 <filename> <db_login> <ftp_host> <ftp_user> <ftp-password> <ftp-catalog>
	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


## .bad file:


	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_pwd=$ARGV[4] ;
	$loggfile="$catalog/proc/ftplog.$$" ;
	$programname="EDL400BA" ;

	$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";

	foreach $file ($ftp->ls) {
	if ($file =~ /^e.*/ ) {
	$ftp->get($file) or die "Can't get the file $file\n";
	$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";


## .log file:



	# 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;

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

	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;

Posted by Perlsomewhat 2019-11-17 12:33:43

No Ans Posted

Please login to comment

Log In

Ask New Question