I want to run a shell script placed on Linux server when a stored procedure is called.
The below code works like a charm if the script is placed on the same server where database is installed, say "Linux Server A".
Database Version: Oracle Database 12c Linux Version: Red Hat Linux 7
begin
dbms_scheduler.create_credential
(
credential_name => 'my_credential',
username => 'user',
password => 'pass'
);
end;
/
create or replace procedure RunShell
as
begin
dbms_scheduler.create_job
(
job_name => 'shell_scripts_job',
job_type => 'executable',
number_of_arguments => 1,
job_action => '/usr/bin/sh',
auto_drop => true,
credential_name => 'my_credential'
);
dbms_scheduler.set_job_argument_value(job_name=>'shell_scripts_job', argument_position=>1, argument_value=>'/u01/Script.sh');
dbms_scheduler.enable('shell_scripts_job');
dbms_scheduler.run_job(job_name=>'shell_scripts_job');
END;
/
EXECUTE RunShell;
The issue is, my DB is installed on "Linux Server A" and the shell script I want to run is on "Linux Server B".
This script performs some operations which has to be done "Linux Server B". One of the main functions is that it starts/stops another application residing on "Linux Server B".
How can I achieve this ?