As root , running script as different user with su - problem

Dear All

I am running into a situation where I am running a script as another user lets say oracle using su command as below, and the script fails because the .profile of oracle is not executed so the environment variables are not set.

cat /etc/passwd | grep oracle
oracle:!:400:101::/app/oracle:/usr/local/bin/bash

Now, I logegd in as root and did this :

su - oracle -c test.sh

test.sh is
#!/bin/sh
echo "I am here"
env

The output has hello from the echo command but the env does not show any ORACLE variables from .profile of oracle user or even from .bash_profile. I alos verified by adding a simple sqlplus block , it failes with sqlplus not found due to missing environment variables.

Any ideas ?

Thanks in advance !

oracle's profile is .profile or .bash_profile?

Oracle uses .profile , I also tried with .bash_profile but it did not help

surprisingly, it works fine when user's defaultshell in /etc/passwd is changed to ksh or csh (with .cshrc in home) .

The only problem is when the user is set to use bash

Would it be possible to just set the variables within the script? I know that's not ideal but it may be a work-around.