LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 06: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, 06:40 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
$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 06:42 AM.
 
1 members found this post helpful.
Old 11-23-2012, 06: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, 06:54 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
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, 02:23 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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



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 06:14 AM
[SOLVED] script not exporting variables divyashree Programming 17 06-08-2011 05:27 AM
exporting variables gecoool Programming 2 10-25-2005 01:17 AM
exporting variables in Perl nbp Programming 1 11-18-2003 08:35 AM
exporting global variables neo77777 Programming 6 09-18-2002 01:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 03:30 PM.

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
Open Source Consulting | Domain Registration