LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices



Reply
 
Search this Thread
Old 11-23-2012, 07:36 AM   #1
cyoung75
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Rep: Reputation: Disabled
Exporting Variables from Other Profiles


Hi

I'm trying to put together an init script to stop and start Ingres on a few machines. The problem is that the hosts have differently engineered Ingres installations so the bin type folders are in different locations.

Ideally I would like a '1 script fits all' and the idea we were working with was calling the .profile of the ingres user which always sits in /home/ingres.

The script I have so far is as follows:

Code:
su - ingres -c ". $HOME/.profile"
  
echo $II_SYSTEM
echo $PATH
echo $LD_LIBRARY_PATH
the problem is, the echo commands are showing the variables for root and not for ingres.

If I go through this step by step I get the expected results i.e. the ingres variables.

Can anyone please help?
 
Old 11-23-2012, 07:40 AM   #2
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,159

Rep: Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364
$HOME is evaluated as the home of the current user (=root). Probably you would write ~ingres/.profile instead
Also the result of -c ". command" will be valid only inside the su - ingres shell, after returning to root you will loose that settings. Probably you only need . ~ingres/.profile without su - ingres -c

Last edited by pan64; 11-23-2012 at 07:42 AM.
 
1 members found this post helpful.
Old 11-23-2012, 07:48 AM   #3
cyoung75
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
$HOME is evaluated as the home of the current user (=root). Probably you would write ~ingres/.profile instead
Also the result of -c ". command" will be valid only inside the su - ingres shell, after returning to root you will loose that settings. Probably you only need . ~ingres/.profile without su - ingres -c
thanks for that

I had already considered running the profile without the su command but didn't want to break roots profile because PATH and LD_LIBRARY_PATH already exist. Is that likely to happen?
 
Old 11-23-2012, 07:54 AM   #4
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,159

Rep: Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364
If you really want to say thanks please press YES in the bottom right corner.

usually the profiles (like ~ingres/.profile) will only extend PATH and LD_LIBRARY_PATH, that will not cause any problem, but if you are in doubt just check it!
 
1 members found this post helpful.
Old 11-26-2012, 03:23 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
The main point is that as soon as this line completes
Code:
su - ingres -c ". $HOME/.profile"
you've exited the ingres env and are back to root.
You need to put everything you need into a script and than call it like you called the profile file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
exporting variables bard Linux - General 3 11-23-2012 07:14 AM
[SOLVED] script not exporting variables divyashree Programming 17 06-08-2011 06:27 AM
exporting variables gecoool Programming 2 10-25-2005 02:17 AM
exporting variables in Perl nbp Programming 1 11-18-2003 09:35 AM
exporting global variables neo77777 Programming 6 09-18-2002 02:46 PM


All times are GMT -5. The time now is 12:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration