Just_ME has asked for the wisdom of the Perl Monks concerning the following question:
Hallo
I'm in need of some help. I can't really narrow the Problem down. I have some really Basic Perl Program which should help me to get Protokoll my testing of Oracle SQL Scripts a Little swifter. in most Cases it runs ver well for my Needs. But from time to time without any reasoning it rejects some files. here is the Errormessege i recieve.
--------------------------------------------------------------------------------.fad fuer command test ist /edvtest/cdk/kuda_537/TP/TP_chk_mjm.sql :Keine Datei und kein Verzeichnis at /edvtest/cdk/shellscripts//my_uti +ls.pm line 440_chk_mjm.sql ', 1) called at /edvtest/cdk/shellscripts/Testframework_v2/MANAGE_ORAC +LE.pm line 413 ') called at /edvtest/cdk/shellscripts/Testframework_v2/TEST_SQL.pm li +ne 201/TP/TP_chk_mjm.sql ') called at /edvtest/cdk/shellscripts/Testframework_v2/TEST_SQL.pm li +ne 65jm.sql ') called at /edvtest/cdk/shellscripts/Testframework_v2/TEST_SQL.pm li +ne 29est/cdk/kuda_537/TP/TP_chk_mjm.sql ', '\u20ac') called at ./consol_output.pl line 135', 'DBI::db=HASH(0x4 +089f718)', 'test\u20ac/edvtest/cdk/kuda_537/TP/TP_chk_mjm.sql the packages i use are as following <code> #!/usr/bin/perl package TEST_SQL; use strict; use warnings; use lib $ENV{'HOME'} . "/shellscripts/"; use lib $ENV{'HOME'} . "/modules"; use DBI; use DBD::Oracle; use Getopt::Long; use Crypt::OpenSSL::RSA; use Carp; use POSIX; use utf8; use MANAGE_ORACLE; use my_utils; ... sub handle_ctctl_line { my ($pname,$dbh,$orders,$seperator) = @_; my @return; my @orderlist = split($seperator,$orders); my $do_what = shift @orderlist; if ("test" eq "$do_what") { my ($sqlpath,@params) = @orderlist; @return = ctctl_test($pname,$dbh,$sqlpath,@params); } elsif ("proc" eq "$do_what") { my ($package,$procedure,@params) = @orderlist; @return = MANAGE_ORACLE->start_procedure($dbh,$package,$procedure, +@params); } elsif ("pause" eq "$do_what") { push @return, undef; push @return, "pause"; } elsif ("text" eq "$do_what") { @return = ctctl_text($pname,@orderlist); } elsif ("line" eq "$do_what") { @return = ctctl_line($pname,@orderlist); } elsif ("start" eq "$do_what") { #param 1 immer prog_name, param2 immer extension, param3 Shell_par +ameter @return = ctctl_start($pname,$dbh,@orderlist); } elsif ("plsql" eq "$do_what") { @return = ctctl_plsql($pname,$dbh,@orderlist); } elsif ("sqlplus" eq "$do_what") { #nicht vergessen $dbh ist in diesem context kein db-handle sonder +ein dbcon; @return = ctctl_sqlplus($pname,$dbh,@orderlist); } else { push @return, undef; push @return, "empty"; } return @return; } ... sub ctctl_test { my ($pname,$dbh,$sqlpath,@params) = @_; my $output = pre_result($pname,$sqlpath,@params); my @return = MANAGE_ORACLE->call_sql_stmt($dbh,$sqlpath,undef,@param +s); my ($is_ok,$e_code,$e_msg,$o_csv,$o_reccs,$o_cols) = @return; if ($is_ok && $o_reccs >= 0) { $output = $output . rewe_utils->union_array(rewe_utils->format_csv +_txt($o_csv,$o_reccs,$o_cols)); $output .= process_rownumber($o_reccs); $return[3] = $output; } return @return; } ... sub pre_result { my ($pname,$stmtpath,@params) = @_; my $return = "Abfragezeitpunkt: " . (strftime "%d.%m.%Y %H:%M:%S", l +ocaltime) . "\n" . "Script: $stmtpath\n"; my $sqlstmt = MANAGE_ORACLE->get_statement($stmtpath,@params); $return .= "Statement:\n" . $sqlstmt . "\n\n"; return $return; } ---------------------------------------------------------------------- +------------------- #!/usr/bin/perl package MANAGE_ORACLE; use strict; use warnings; use DBI; use DBD::Oracle; use Carp; use utf8; use lib "/edvtest/cdk/shellscripts/"; use my_utils; sub get_statement { my ($pname,$sqlpath,@params) = @_; my $sqlstmt = my_utils->read_file($sqlpath,1); if (scalar(@params) > 0) { my $counter = 1; foreach my $param (@params) { $sqlstmt =~ s/(:$counter)/$param/g; $counter++; } } return $sqlstmt; } ---------------------------------------------------------------------- +------------------ #!/usr/bin/perl package rewe_utils; use strict; use warnings; use Carp; use utf8; my $linesize = 75; my $moddir = $ENV{'HOME'} . "/modules"; print $moddir; #use lib $moddir; use Crypt::OpenSSL::RSA; use Convert::PEM; use MIME::Base64; use File::Basename; use XML::Simple; use ORADB; use POSIX; sub read_file { my ($pname,$path,$encoding) = @_; my $return = undef; local $/ = undef; if ($encoding) { open (my $fh, "<:encoding(UTF-8)", $path) or confess "Uebergebener + Pfad nicht korrekt: /n" . $0 . ': open' . $path .':' . $!; { local $/; $return = <$fh>; } close $fh; $return = convert_problems($pname,$return); } else { open (my $fh, '<', $path) or confess "Uebergebener Pfad nicht korr +ekt: /n" . $0 . ': open' . $path .':' . $!; { local $/; $return = <$fh>; } close $fh; } chomp $return; return $return; }
the start Programm uses the followig
#!/usr/bin/perl use strict; use warnings; use lib $ENV{'HOME'} . "/shellscripts/"; use lib $ENV{'HOME'} . "/modules"; use lib $ENV{'HOME'} . "/shellscripts/Testframework_v2"; use Getopt::Long; use Crypt::OpenSSL::RSA; use Carp; use POSIX; use utf8; use TEST_SQL; use MANAGE_ORACLE; use my_utils;
Critics and help would be great as i am fairly new to the whole Perl theme and i sadly have no real Input on Things i do
thanks in advance Christian
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with file encoding
by Corion (Patriarch) on Mar 28, 2019 at 09:24 UTC | |
|
Re: Problem with file encoding
by haj (Vicar) on Mar 28, 2019 at 09:33 UTC | |
by Corion (Patriarch) on Mar 28, 2019 at 09:37 UTC | |
|
Re: Problem with file encoding
by Just_ME (Novice) on Mar 28, 2019 at 10:35 UTC |