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 Sql scripts accross db2 jnimz Shell Programming and Scripting 4 10-23-2008 06:49 AM
Running scripts through cronjob. jitu.jk Shell Programming and Scripting 3 06-23-2008 06:33 PM
scripts running under different users csnewbie UNIX for Dummies Questions & Answers 1 02-14-2007 04:52 PM
Running scripts parallely santho UNIX for Dummies Questions & Answers 4 07-23-2006 12:42 PM
Running three scripts parallelly anwarsait Shell Programming and Scripting 1 07-18-2006 01:20 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
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
Running scripts via su

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 .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 profile

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

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
Please, don't hijack other people's threads - start a new thread!

Post moved to new thread -- Otheus

Last edited by otheus; 02-11-2009 at 07:03 AM..
  #3 (permalink)  
Old 02-11-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,864
The user "bin" doesn't have a home directory, or if it does, it's not the one shared by root, and so there is no profile to load. You can fix this by going into the passwd table and giving bin a home directory, such as "/root" or "/" or a new directory like "/home/bin" and installing an appropriate .*shrc file there.
  #4 (permalink)  
Old 02-11-2009
ravi.sri24 ravi.sri24 is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 9
Quote:
Originally Posted by otheus View Post
The user "bin" doesn't have a home directory, or if it does, it's not the one shared by root, and so there is no profile to load. You can fix this by going into the passwd table and giving bin a home directory, such as "/root" or "/" or a new directory like "/home/bin" and installing an appropriate .*shrc file there.

Hi Thanks for the reply, I have the bin direcotry and when the run the start.sh script file it's running fine but when am running the start.sh using the root shell by using the su command it's not working
  #5 (permalink)  
Old 02-11-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,864
When you run su as you explained, it tries to load the environment of "bin". If you want root's environment instead, use:

Code:
su bin -c start.sh
This will use the current environment but run start.sh as user bin. If you want to run it with root's environment, you must do as I described in my previous post.
  #6 (permalink)  
Old 02-11-2009
ravi.sri24 ravi.sri24 is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 9
Quote:
Originally Posted by otheus View Post
When you run su as you explained, it tries to load the environment of "bin". If you want root's environment instead, use:

Code:
su bin -c start.sh
This will use the current environment but run start.sh as user bin. If you want to run it with root's environment, you must do as I described in my previous post.

When i run the below command i want's bin environment varibales loaded but it's not loading so my process getting failed with the the reason NoClassDefination found error

su - bin -c "start.sh"
  #7 (permalink)  
Old 02-11-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,864
Since you are not understanding my posts, I will let someone else help you.
Sponsored Links
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 03:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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