The UNIX and Linux Forums  


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
As root , running script as different user with su - problem dbsupp Shell Programming and Scripting 4 12-18-2008 01:28 AM
run a script on logout by a non-root user harsha10 Shell Programming and Scripting 6 06-16-2008 04:14 PM
Shell script to find when user su'ed to root jrvilino Shell Programming and Scripting 1 03-05-2008 10:31 AM
crontab and shell script that executes a sql. radhika Shell Programming and Scripting 6 06-07-2005 12:33 AM
root executes a script as another user tads98 Shell Programming and Scripting 1 05-17-2005 09: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 02-10-2009
ravi.sri24 ravi.sri24 is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 9
root executes a script as another user

Hi All,
Am using the below command to start my application using the root user
su - bin -c "/home/bin/test/start.sh"

but am getting the error becaue i have set some environment varibales in bin's .profile

when i execute the command start.sh by logging directly into bin account it's working fine

But where as if i ran the above command using the root user am getting error seems it's not loading the bin's .profile file

Please advise me how to load the bin's profile while using the su
  #2 (permalink)  
Old 02-10-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,330
One way is to "source" the .profile of bin in your script, something like:


Code:
. /home/bin/.profile

Regards
  #3 (permalink)  
Old 02-10-2009
ravi.sri24 ravi.sri24 is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 9
Quote:
Originally Posted by Franklin52 View Post
One way is to "source" the .profile of bin in your script, something like:


Code:
. /home/bin/.profile

Regards
Thanks for the reply, I have tried the way you suggested but no luck still it's not taking the bin's environment varibales
  #4 (permalink)  
Old 02-10-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,330
Quote:
Originally Posted by ravi.sri24 View Post
Thanks for the reply, I have tried the way you suggested but no luck still it's not taking the bin's environment varibales
Should work, did you used the right path? Have you placed the line above the other commands in your script?

Regards
  #5 (permalink)  
Old 02-10-2009
ravi.sri24 ravi.sri24 is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 9
Quote:
Originally Posted by Franklin52 View Post
Should work, did you used the right path? Have you placed the line above the other commands in your script?

Regards
Yes i have placed properly only, below is the command

./home/bin/.profile

su - bin -c "/opt/bin/test/receiver/start.sh
  #6 (permalink)  
Old 02-11-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,330
There's must be a space between the dot and the slash:


Code:
. /home/bin/.profile

Regards
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 PM.


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