Write to file without redirector


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Write to file without redirector
# 1  
Old 03-28-2017
Bug 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 -
Code:
echo -e "# System Generated Data" > filename.out

Q is, how can I write to the file without using any sort of redirector?
Code:
<command> <message> <write to file>  # No redirectors.

Thanks for the suggestions.

Last edited by rbatte1; 03-29-2017 at 10:32 AM.. Reason: Converted to link and added CODE tags
# 2  
Old 03-28-2017
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:
Code:
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.

Last edited by jim mcnamara; 03-28-2017 at 09:04 PM..
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 03-29-2017
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?
Code:
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.
This User Gave Thanks to rbatte1 For This Post:
# 4  
Old 03-29-2017
I think you need to save the script somewhere and from Oracle scheduler run
Code:
/path/to/script

This User Gave Thanks to MadeInGermany For This Post:
# 5  
Old 03-29-2017
Thanks guys... Jim's suggestion did the trick. Script is working as expected from scheduler now.

Thanks again guys.

aBBy007
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help to write a shell script to convert text file to excel file.

Hi Everyone, I want your help to write a script which will take text file as input and on the basis of delimiter ":"script will create excel sheet. Example input: IpAdress:InstanceName:Port:ServerName 10.255.255.1:abc:2232:xyz_abc Output should be an excel sheet like below: Column... (8 Replies)
Discussion started by: akabhinav18
8 Replies

2. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

3. Shell Programming and Scripting

Need to search a particular String form a file a write to another file using perl script

I have file which contains a huge amount of data. I need to search the pattern Message id. When that pattern is matched I need to get abcdeff0-1g6g-91g3-1z2z-2mm605m90000 to another file. Kindly provide your input. File is like below Jan 11 04:05:10 linux100 |NOTICE... (2 Replies)
Discussion started by: Raysf
2 Replies

4. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

5. Shell Programming and Scripting

Extract data from an XML file & write into a CSV file

Hi All, I am having an XML tag like: <detail sim_ser_no_1="898407109001000090" imsi_1="452070001000090"> <security>ADM1=????</security> <security>PIN1=????</security> <security>PIN2=????</security> ... (2 Replies)
Discussion started by: ss_ss
2 Replies

6. Programming

Some how the open(file,flag, acc) returns 0 and write to the screen, instead of the file ???

I am out of idea what to do to resolve the problem! I need to use the open(file, for.., access) function to write a file. Never have the situation like that: it is return 0 - zero. As a result all write(..) going to the screen! What the problem it could be? I do not even know... (2 Replies)
Discussion started by: alex_5161
2 Replies

7. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

8. UNIX for Dummies Questions & Answers

Serial port redirector

I need make serial data from virtual serial ports available on a TCP/IP network. For communications with hardware COM ports to send and receive serial data over a local network or the Internet. Example: POSIX machine (/dev/ttyS0) <--- TCP/IP ---> Windows machine COM1 Please help! I try use... (0 Replies)
Discussion started by: steel98
0 Replies

9. UNIX for Advanced & Expert Users

UNIX Serial Port Redirector

Hi , I need to have an application where in I am able to create a virtual Serial port on a UNIX machine for a remote device which is accessible by a IP address and a port number (by terminal server). Both the machine and the remote device are on the same network. So after this application is... (1 Reply)
Discussion started by: naveenkj
1 Replies
Login or Register to Ask a Question