Solved

Cross-shell environment variables

Posted on 2002-04-22
6
462 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
  • 2
  • 2
  • 2
6 Comments
 
LVL 16

Expert Comment

by:Peter Kwan
Comment Utility
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
Comment Utility
...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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 total points
Comment Utility
# 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
Comment Utility
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
Comment Utility
> 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
good comptia a+ teacher? 4 73
Ubuntu vs. Debian 4 79
Linux: disable vim auto-comment 7 61
AWS CLI issues with Tags 3 24
After running Ubuntu some time, you will be asked to download updates for fixing bugs and security updates. All the packages you download replace the previous ones, except for the kernel, also called "linux-image". This is due to the fact that w…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now