Solved

Invoke Shell script using dbms_scheduler

Posted on 2011-03-15
3
1,177 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

713 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