Oracle calls the executuble specified in the external job . directly, i.e. without shell and in empty surroundings. From Topicaster comment :
Replaced sqlplus with a softlink script that sets variables and runs the real sqlplus already. I don't want to leave such a gomosyatin, I want a beautiful solution.
This is actually the right decision.
Or you can create a universal task launching shell with reading login scripts, and then run the desired program in it (or even built-in, function, etc.):
begin dbms_scheduler.create_job ( job_name => '"SH1"."shell_exec"', job_type => 'EXECUTABLE', job_action => '/bin/bash', number_of_arguments => 2, start_date => to_date('2099','yyyy'), repeat_interval => NULL, end_date => NULL, enabled => false, auto_drop => false, comments => 'execute some command in bash'); dbms_scheduler.set_job_argument_value( job_name => '"SH1"."shell_exec"', argument_position => 1, argument_value => '-lc'); dbms_scheduler.set_job_argument_value( job_name => '"SH1"."shell_exec"', argument_position => 2, argument_value => 'env > ~/env.out; echo "env ok" >/dev/stderr; exit 0'); dbms_scheduler.enable('"SH1"."shell_exec"'); end; / exec sys.dbms_scheduler.run_job('"SH1"."shell_exec"');
In ~ / env.out output of the full user environment in the mode of non-interactive login.
Another example of launching and viewing output to the standard error stream:
begin dbms_scheduler.set_job_argument_value( job_name => '"SH1"."shell_exec"', argument_position => 2, argument_value => 'echo "try some command here" >/dev/stderr ; exit 0'); dbms_scheduler.run_job('"SH1"."shell_exec"'); end; / select additional_info from dba_scheduler_job_run_details where job_name = 'shell_exec'; ADDITIONAL_INFO STANDARD_ERROR="env ok" STANDARD_ERROR="try some command here"
Chapter 28.3.1.2.1 About External Jobs , among other things, describes how to set up the user and group with which the task will run.