?
Solved

Cross-shell environment variables

Posted on 2002-04-22
6
Medium Priority
?
478 Views
Last Modified: 2008-03-17
Dear group,

Is there a way to set a certain environmental ($ENV) variable so that no matter what shell is started, by no matter which user, the variable is present.

More specifically, I want to set $ENV{'PERL5LIB'} to point to my program directory so that no matter where my programs are started from, no matter which user (including nobody and root), the proper directory will be included in @INC.

...but I'm getting ahead of myself. Any help is appreciated.

Thanks,
- Tonyboy
0
Comment
Question by:Tonyboy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 6960745
Add the following your /etc/profile (or equivalent "profile" file, depending on your linux distribution):

set PERL5LIB="value"
export PERL5LIB

or if your distribution supports setenv, use

setenv PERL5LIB "value"
export PERL5LIB

Please tell us if this does not work for you.
0
 

Author Comment

by:Tonyboy
ID: 6960766
...but won't this simply add the PERL5LIB variable to the bash shell users? tcsh, csh and sh shell users don't source the /etc/profile file, as far as I know.
0
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 6960811
As far as i know, for sh users,  they are using /etc/profile.
For csh,tcsh users, they are using /etc/cshrc.login

If you have both, then you should edit both files.
0
WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

 
LVL 51

Accepted Solution

by:
ahoffmann earned 400 total points
ID: 6962057
# in /etc/csh.cshrc (for csh, tcsh)
setenv PERL5LIB "value"

# in /etc/profile (for ash, bash, ksh, pdksh, sh, zsh, and much more)
set PERL5LIB="value"
export PERL5LIB
# keep in mind that bash might make trouble, 'cause there are dozent of ways where bash does not use /etc/profile at all
0
 

Author Comment

by:Tonyboy
ID: 6962636
What about jobs run by cron? What about scripts run by Apache? Do these files get sourced when the shells are started by other programs?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6964830
> What about jobs run by cron?
cron uses sh by default, so /etc/profile matches.
If the user uses another shell in her/his crontab, they need to source the appropriate scripts, but AFAIK the cannot cross the limits set by the parent shell (never checked it).

> What about scripts run by Apache?
Apache uses its own user (www, nobody), usually. So the same applies as for cron.

> .. shells are started by other programs?
Depends on the shell.
But i.g. you cannot cross the limits set by the parent.
0

Featured Post

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question