LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-23-2009, 08:45 AM   #1
voyciz
Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 425

Rep: Reputation: 40
Can't set root env variables in script?


Anyone know why I wouldn't be able to run a script as root that uses export commands to set up environment variables? Running Slackware64 13.0. This is really annoying because if I run /etc/profile.d/32dev.sh as root, nothing happens to root's environment. I can type the commands out at the prompt and that's all good, but it would be much more convenient to use a script. Thanks guys.
 
Old 09-23-2009, 09:01 AM   #2
tux_dude
Member
 
Registered: Dec 2008
Distribution: Slackware64 Current
Posts: 277

Rep: Reputation: 41
You will need to use
Code:
. /etc/profile.d/32dev.sh
Without the '.' the script will run in a sub-shell. All the environment variables are lost once the sub-shell closes.
 
Old 09-23-2009, 03:36 PM   #3
voyciz
Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 425

Original Poster
Rep: Reputation: 40
Thank you! Simple enough. You know, I noticed that dot in Alien Bob's wiki and thought that it was irrelevant. Makes much more sense now.
 
Old 09-23-2009, 07:44 PM   #4
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
Quote:
if I run /etc/profile.d/32dev.sh as root, nothing happens to root's environment.
Running the script will only use the variables inside the 32dev.sh script. To export the varibles into the parent environment you have to source the 32dev.sh script.
 
  


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
how to set env variables for oracle 10g xe ?? y2raza Linux - Newbie 11 03-05-2008 10:13 AM
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 11:33 AM
Cannot set LD_LIBRARY_PATH in .cshrc (able to set other env variables) senthilpr_in Linux - Newbie 4 02-26-2007 12:46 PM
how do you set an env variable from within a csh script? BrianK Linux - General 3 05-26-2004 02:16 PM
where are the env variables set on boot? Pete Dogg Linux - Software 1 09-10-2003 02:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:12 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
Open Source Consulting | Domain Registration