Solved

Invoke Shell script using dbms_scheduler

Posted on 2011-03-15
3
1,118 Views
Last Modified: 2012-05-11
I am using dbms_scheduler to invoke a shell script. The shell script requires one input parameter.

begin
   dbms_scheduler.create_job
   (
      job_name                  => 'DEMO_SHELL_JOB',
      job_type                  => 'EXECUTABLE',
      job_action                => '/home/test/test.sh',
      number_of_arguments       => 1,
      start_date            => sysdate + 10/1440,
      enabled                   => false,
      auto_drop                 => true,
      comments                  => 'Run shell-script'
   );
end;
/

Enabled => false because the argument needs to be provided before I enable the job.
I am providing the argument as below:
begin
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
   job_name                  => 'DEMO_SHELL_JOB',
   argument_position            => 1,
   argument_value            => '/usr/tmp/abc.trc');
end;
/

I am stuck here.. Can you point how to enable the job again..
My requirement is to run the shell script once for the input argument that I provide. I also want the job to be dropped after it executes (auto_drop=> true).
Am I doing it the correct way..

Thanks in advance...
0
Comment
Question by:sanpradeep
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Peter Kwan earned 250 total points
ID: 35144942
Manually enabling a job:

dbms_scheduler.enable('DEMO_SHELL_JOB');
0
 

Author Comment

by:sanpradeep
ID: 35144987
Now i have enabled the job.. but my job is failing...
 select log_date
 ,      job_name
 ,      status
 from dba_scheduler_job_log
where  job_name = 'DEMO_SHELL_JOB';

15-MAR-11 11.37.12.559177 PM -07:00
DEMO_SHELL_JOB
FAILED

I have scheduled another job with zero arguments.. and this job executed successfully..
In the current scenario, am I passing the argument correctly... Does the argument I pass goes to the shell script as $1.

Also I executed the shell script directly in unix.. it got executed. So there is no problem with the script that I am trying to execute...
I doubt there is some problem with the argument I pass..
Please help...

0
 

Author Comment

by:sanpradeep
ID: 35146142
Thanks pkwan..

The issue was related to path settings... It is resolved now..
Thx for your help...
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now