Hi Experts,
I am writing a shell script into the oracle directory through PL/SQL.
To execute that I need to give the UNIX command chmod +x schellscript.sh
How to execute UNIX command from PL/SQL.
version
------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
SET SERVEROUTPUT ON;
DECLARE
script_file varchar2(40) := 'my-temp-script.sh';
script_data varchar2(4000);
MyFile utl_file.file_type;
d varchar2(4000);
begin
-- Open file
MyFile := utl_file.fopen('UPNCOMMON_DIR',script_file,'w');
-- Write data to file
script_data := '#!/bin/bash' || chr(10) || '. /etc/profile' || chr(10)|| 'echo "hello world"';
utl_file.put_line(MyFile, script_data, FALSE);
-- Close file
utl_file.fflush(MyFile);
utl_file.fclose(MyFile);
dbms_scheduler.create_job(
job_name => 'TEST_shl',
job_type => 'EXECUTABLE',
job_action => '/home/upncommn/',
number_of_arguments => 2,
start_date => SYSTIMESTAMP,
enabled => FALSE,
credential_name => 'NEWOS',
auto_drop => FALSE);
dbms_scheduler.set_job_argument_value('TEST_shl', 1, '/workfile/'||script_file);
dbms_scheduler.set_job_argument_value ('"TEST_shl"', 1, 'chmod +x testingscript.sh');
dbms_scheduler.enable('TEST_shl');
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(sqlerrm);
END;
/
Thanks.