Question

  • Creator
    Topic
  • #2143357

    Help understand Perl script(s)

    by perlsomewhat

    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.

You are posting a reply to: Help understand Perl script(s)

The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our Community FAQs for details. All submitted content is subject to our Terms of Use.

All Answers

  • Author
    Replies
    • #2421636

      First file:

      by perlsomewhat

      In reply to Help understand Perl script(s)

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

    • #2421635

      2nd file .pl

      by perlsomewhat

      In reply to Help understand Perl script(s)

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

    • #2421634

      3d file .load

      by perlsomewhat

      In reply to Help understand Perl script(s)

      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;

    • #2421633

      1st file .bat

      by perlsomewhat

      In reply to Help understand Perl script(s)

      @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

Viewing 3 reply threads