Solved

Cross-shell environment variables

Posted on 2002-04-22
6
476 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to configure linux OS using Ubuntu 7 69
Recover Lacie Edmini data. 11 65
IMAP copying tool 14 48
DB2 9.7 Grant Execute SP 4 16
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

733 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