I am replacing two Oracle 11g servers with 12c

TL/DR - when shelling out to a run an O.S. file, the PATH environmental variable is not being set.

On the old servers we use an external library to allow executing commands from the shell. This same shell was set up on the new 12c servers.

void sh(char *command) {
  int num;
  num = system(command);

A library was created and a procedure set to call it.

   NAME "sh"
   LIBRARY shell_lib
   PARAMETERS (cmd string);

Everything works great - except that we lose the PATH environment variable when going to the shell. All the other environment variables are still there, just PATH is reset as blank. This means that even to run something as simple as 'ls' or 'cp' you have to use the full path of '/bin/ls' or '/bin/cp'

I ran the following to see what variables were being set:

execute dbutilities.shell('/usr/bin/printenv > /tmp/envvariables.txt');

A snippet of the results show that PATH has been reset to nothing. (Note that even custom environmental variables such as email notifications are still set in this file). Also, when connecting in via ssh the path is set correctly for this user. It is only when dropping to a shell from Oracle that we have this issue.


I am getting the same issue on both servers. Has anyone run across this? Any suggestions on a fix?

  • Just call setenv ("PATH", "/bin:/usr/bin", 1); before invoking system(). Or use execve(). The most probably 12c does that due to security concerns. Feb 20, 2014 at 13:24
  • I had heard that about 12c but cannot find documentation of it. I have submitted an SR with Oracle as well.
    – user739866
    Feb 20, 2014 at 13:29

1 Answer 1


If you're on at least 11g, the method is deprecated, as DBMS_SCHEDULER functionality is capable of calling a shell script or C program.

However, if you really want to do it this way, you can set ENVS in the definition of the SID_LIST_your_external_proc_listener_name.

See MOS Doc ID 99136.1 for more details.

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.