Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a perl script with Oracle 1

Status
Not open for further replies.

onirike

Programmer
Aug 3, 2000
91
0
0
CA
Hi!

We have a simple problem here and I hope with a simple solution. We are running a perl script using the UNIX scheduler (crontab). This script is importing information from a file and sending this information in an Oracle DB.
If I run the script manually (without the scheduler) everything works fine. If I run the script using the scheduler I get a core dump. We discovered some part of the problem. It seems that when we are using the scheduler, the UNIX ORACLE environment variables are different. This cause to have a different ORACLE home variable which create a problem.

We tried modifying on the fly (just before running the script with the scheduler) these variables but it's not working. Any ideas or suggestions?

Any help would be appreciated,
Thanks
Chris ;-)
 
Try modifying the environment variables IN the script itself. You should be able to do it like this:
Code:
$ENV{'varname'} = "value";
If that doesn't work, I've got another idea or two that might.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Hi Tracy!

Thanks for your reply. We already tried to modify the environment variables in the script itself and it seems that even if we do modify the variable they don't change. Maybe we are not authorized to change an environment variable. I don't know.

Any other ideas you may have would be appreciated.

Thanks a lot for your help,
Chris ;-)

 
Hi, this may be related.
We are running Oracle 8.1.6 on Solaris 8 (Intel) and I wrote the following to see if the snort (IDS) software is running:

--start--
#! /usr/bin/perl

use DBI;

$sensor_id = <$ARGV[0]> or die(&quot;Sensor id not passed in command line&quot;);

$heartbeat = `ps -ef | grep snort`;

if ($heartbeat=~/(snort)/) {
$status = 'UP'
}
else {
$status = 'DOWN'
}

@status_time = localtime();
$status_time=&quot;to_date('&quot; . ($status_time[4]+1) . &quot;-$status_time[3]-&quot; . ($status_time[5]+1900) . &quot; $status_time[2]:$status_time[1]:$status_time[0]','MM-DD-YYYY HH24:MI:SS')&quot;;

$db = DBI->connect(&quot;dbi:Oracle:host=blah;sid=blah&quot;,'blah','blah');
$insert = $db->prepare(&quot;UPDATE SENSOR SET SENSOR_STATUS='$status', STATUS_TIME=$status_time
WHERE SID=$sensor_id&quot;)
$insert->execute;
$insert->finish;
$db->finish;
--end--

This runs and actually updates the row in Oracle, but causes a &quot;segmentation fault-core dumped&quot; thingy. I don't know what's causing this either. Any ideas?
Brad Gunsalus
Cymtec Systems, Inc.
bgunsalus@cymtec.com
 
Did you try modifying the environment variables in the cron job itself? If so, did you try exporting the modified environment variables. The syntax for that is just:
Code:
export varname
That's supposed to make environment variable changes visible outside the current shell.

Also, have you tried adding a command in the cron job to log in as a different userid, like the userid that you used to test it?
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Tracy!

Your last idea about logging in the cron job may the solution to our problem. I will talk to my UNIX administrator to ask him how to do this and we will try it.
Many many many thanks for your help, it's really appreciated!

I'll keep your informed if it's working or not...

Thanks,
Chris ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top