I have compiled a perl script of using perlapp and it will run
successfully in a regular shell, but things get ugly when trying to 
run it from cron.  My first approach is to try and set the 
environment inside the perl script itself.  I'd like to try it this way 
as opposed to calling some other script to set the environment and then 
having it run the actual perl program.

Here is the cron output:
~~~
>From ouser Tue Nov  1 16:50:00 2005
Date: Tue, 1 Nov 2005 16:50:00 -0500 (EST)
From: ouser
Message-Id: <[EMAIL PROTECTED]>
To: ouser
Subject: Output from "cron" command
Content-Length: 360

Your "cron" job on oracledb
/scripts/tempmon

produced the following output:

Can't load 'auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: 
ld.so.1: /scripts/tempmon: fatal: auto/DBD/Oracle/Oracle.so: open 
failed: No such file or directory at /PerlApp/DynaLoader.pm line 212.
 at perlapp.pl line 1361
BEGIN failed--compilation aborted at tempmon.pl line 29.



~~~~~
Here is the code in shortened form. It is hardcoded quite a bit for 
sake of resolving this problem.  You may see here that I simply want to 
process a query every so often and act according to its output.  I'm 
assuming the "Dynamic Loader" is defaulting to look in an ActivePerl 
installation directory structure.  Sine perlapp was used to make a 
standalone executable I expect it to find anything extra that it needs 
in the ORACLE_HOME.  
~~~~~
#!/opt/ActivePerl-5.8/bin/perl
my $curhost=`hostname`;
chomp($curhost);

my $dbcon;

if ($curhost eq "host1") {
        $dbcon="HOST1";
        $ENV{ORACLE_HOME}="/u01/oracle/host1db/8.1.7";
        $ENV{TNS_ADMIN}
="/u01/oracle/host1db/8.1.7/network/admin/HOST1_host1";
        $ENV{LD_LIBRARY_PATH}
="/u01/oracle/host1ora/8.0.6/network/jre11/lib/sparc/native_threads:/u01
/oracle/host1db/8.1.7/lib:/usr/dt/lib:/usr/openwin/lib"
} elsif ($curhost eq "host2") {
        $dbcon="HOST2";
        $ENV{ORACLE_HOME}="/u01/oracle/host2db/8.1.7";
        $ENV{TNS_ADMIN}="/u01/oracle/host2db/8.1.7/network/admin/HOST2";
        $ENV{LD_LIBRARY_PATH}
="/u01/oracle/host2ora/8.0.6/network/jre11/lib/sparc/native_threads:/u01
/oracle/host2db/8.1.7/lib:/usr/dt/lib:/usr/openwin/lib"
} else {
        print "Host based failure.\n";
        exit;
}

$ENV{PERL5LIB}="";
$ENV{PATH}="/opt/ActivePerl-5.8/bin:$ENV{PATH}";

use strict;
use warnings;
use DBI;
use DBD::Oracle;
use DBI qw(:sql_types);

my $sql = q{
        <removed>
};

my $dbh;

eval {
        $dbh = DBI->connect("dbi:Oracle:$dbcon",
                                '***', '***',
              {
                   RaiseError => 1,
                   AutoCommit => 0,
                   ora_session_mode => 0
              }
        );
};

if ( $@ ) {
        print('end',"$DBI::errstr\n");
}

exit unless ($dbh);
$dbh->disconnect;  

That did the trick. Thanks.
Bill


$Bill Luebkert wrote:
Bill Platt wrote:

  
Hello,

I have included a section of code below
that is driving me nuts.

If I don't run the Substitution operations,
then I can successfully extract the URL
and the imbedded anchor text from
$parsed_html.

Once I include the Substitution operations,
then I cannot extract the same results.

Even though the output text looks theoretically
correct, I cannot see why any combination of the
Substitution operation breaks my code.

Can you offer any suggestions to me?



if($parsed_html =~ m/href/)
{

$parsed_html =~ s/\s+/ /gs;
$parsed_html =~ s/>/">/gs;
    

The above could cause problems later.

  
$parsed_html =~ s/=http/="http/gis;
$parsed_html =~ s/"+/"/gs;
$parsed_html =~ s/'"/'/gs;
$_ = "$parsed_html";

@urlmatch = (@urlmatch,$2,$4) while m{
     < \s*
     A \s+ HREF \s* = \s* (["'])  (.*?)  (["'])
     \s* > \s* (.*?) \s* <\/a \s* >
    

There is a " before the last > that you will need to account for.

  
}gsix;

print "0=$urlmatch[0]<BR>1=$urlmatch[1]<BR>2=$urlmatch[2]<BR>";
print "3=$urlmatch[3]<BR>4=$urlmatch[4]<BR>5=$urlmatch[5]<BR>";

print "s0=$0<BR>s1=$1<BR>s2=$2<BR>s3=$3<BR>s4=$4<BR>s5=$5<BR>";
print "$_<BR><HR>$parsed_html<BR><HR>";

}
    

my @urlmatch;
my $parsed_html =
  "<A HREF="" class="moz-txt-link-freetext" href="http://www.fubar.com/">http://www.fubar.com/>URL</A>\n<A HREF="" class="moz-txt-link-freetext" href="http://www.fubar2.com/">http://www.fubar2.com/>URL2</A>\n";

if ($parsed_html =~ m/href/i) {

	$parsed_html =~ s/\s+/ /gs;
	$parsed_html =~ s/>/">/gs;
	$parsed_html =~ s/=http/="http/gis;
	$parsed_html =~ s/"+/"/gs;
	$parsed_html =~ s/'"/'/gs;
	$_ = $parsed_html;

	print "\$_=$_\n";
	while (   # note I added "? to the last part of the RE ------v (or just drop the \s*> part)
	  /<\s*A\s+HREF\s*=\s*(["'])(.*?)(["'])\s*>\s*([^<]*)\s*<\/a"*\s*>/gis) {

		# print $n variables out:

		for (1..9) {
			eval "print \"<BR>$_=', \$$_, '\n\" if defined \$$_";
		}

	}
}



  
_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to