Write to file without redirector

Hello Shell scripting Gurus,

I am writing a script to be executed from Oracle Scheduler. This script works flawlessly when executed at the shell prompt, but fails when executed from Oracle Scheduler due to the issues explained in the Oracle Link below:

Guide to External Jobs on 10g with dbms_schedul... | Oracle Community

In short:

## Below script works as part of the script perfectly, but not when executed through Oracle Scheduler -

echo -e "# System Generated Data" > filename.out 

Q is, how can I write to the file without using any sort of redirector?

<command> <message> <write to file>  # No redirectors. 

Thanks for the suggestions.

The oracle scheduler does not have write access to the directory/file, or your script does not cd to a place where the scheduler can write. The /tmp directory is a possibility.
try:

echo -e "# System Generated Data" > /tmp/filename.out 

The scheduler uses streams if I recall correctly. Runs as the oracle user. This is a form of interprocess communication between the oracle kernel and UNIX.

Note: it will likely not write to the same place that the output of DBMS_OUTPUT , UTL_FILE operations or spool is set in pl/sql, so there is probably a filename.out somewhere. IF in fact the oracle user had write privilege to the directory. You may need a directory object created by the DBA to point to where you want to write your pl/sql or sql output to use i.e., /tmp <- this would allow both processes to write to a common directory, /tmp. And a change to the directory name in any scripts.

1 Like

It might come down the account you are running as, the environment set up in the shell you are running and what Jim has already suggested.

I don't have the Oracle Scheduler, but can you write a simple script like this and run it, then examine the syslog?

while read line
do
logger "$line"
done < <(env|sort)

Hopefully that will splat your environment out. You could also try with the set command instead of env and have a look at what you get. Think about PATH, PWD, USER or LOGNAME and examine what else is showing. Perhaps what you want to run is blocked for some other reason.

1 Like

I think you need to save the script somewhere and from Oracle scheduler run

/path/to/script
1 Like

Thanks guys... Jim's suggestion did the trick. Script is working as expected from scheduler now.

Thanks again guys.

aBBy007