The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running script from other user rather than login user rawatds Shell Programming and Scripting 3 01-30-2009 01:18 PM
run a script on logout by a non-root user harsha10 Shell Programming and Scripting 6 06-16-2008 03:14 PM
CDE login Problem for root user only Awadhesh HP-UX 1 08-02-2005 08:58 AM
Running a command or script as root rm-r Shell Programming and Scripting 3 05-27-2005 08:58 AM
root executes a script as another user tads98 Shell Programming and Scripting 1 05-17-2005 08:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-17-2008
dbsupp dbsupp is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 3
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 !
  #2 (permalink)  
Old 12-17-2008
ivhb ivhb is offline
Registered User
  
 

Join Date: Dec 2008
Location: CHINA
Posts: 20
oracle's profile is .profile or .bash_profile?
  #3 (permalink)  
Old 12-17-2008
dbsupp dbsupp is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 3
Oracle uses .profile , I also tried with .bash_profile but it did not help
  #4 (permalink)  
Old 12-17-2008
dbsupp dbsupp is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 3
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
  #5 (permalink)  
Old 12-18-2008
flakblas flakblas is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 13
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:25 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0