Case :
My case is pretty straight forward. I have a Linux server machine. On that server, there are 2 users. One is root and the other is oracle. Now here is the thing, the root user does not know the sqlldr command, this command is recognized by oracle user only.
I have a batch.sh file and in that file i have an sqlldr command that will insert record in the database. When i open terminal using oracle user, that batch.sh file runs according to the expectations. But when I run that batch file from terminal using the root user, it says "./batch.sh: line 3: sqlldr: command not found".
Problem:
Now the problem is, I am calling this batch.sh file from java code, and this java process is started as root. There is no way for me to switch this java process to oracle. However what I am expecting is, that i may switch user before executing the command in the batch.sh file using the root user.
Here is my batch.sh file content.
#!/bin/bash
sqlldr username/password@sid control='/path/toFile/control.txt' log='/path/toFile/Results.log' bad='/path/toFile/BadFile.bad' ERRORS=5000
exit 0
I am expecting something like this.
#!/bin/bash
### Start - Switch user here from root to oracle so that it recognize the following command
sqlldr username/password@sid control='/path/toFile/control.txt' log='/path/toFile/Results.log' bad='/path/toFile/BadFile.bad' ERRORS=5000
### End - Undo the switch that we made above
exit 0
Any help will be highly appreciated.
Thanks