Skip to content
January 20, 2011 / doganay

SHELL SCRIPT EXECUTING IN STORED PROCEDURES

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Hi,
you may use several ways to execute a shell script in a sp.
Here are two of them:

1)

BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM
(
program_name => 'MDOGANAY.PRG_TEST'
,program_type => 'EXECUTABLE'
,program_action => '/tmp/a.sh'
,number_of_arguments => 0
,enabled => FALSE
,comments => 'Test'
);
END;

begin
SYS.DBMS_SCHEDULER.ENABLE(name=> 'MDOGANAY.PRG_TEST');
END;
/

BEGIN
DBMS_SCHEDULER.create_job (job_name => 'MDOGANAY.J_PRG_TEST',
program_name => 'MDOGANAY.PRG_TEST',
start_date => NULL,
repeat_interval => NULL,
end_date => NULL,
enabled => TRUE,
auto_drop => FALSE
);
END;
commit;

begin
DBMS_SCHEDULER.run_job('MDOGANAY.J_PRG_TEST');
end;
/

2)
or simply you can use ‘host’ (less painless one 🙂 )

exec host('ls -ltr');

try and pray 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: