Solved

Cross-shell environment variables

Posted on 2002-04-22
6
475 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
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Use CRON to save a copy of an open file 1 55
How to retrieve remote exit code when using rsh from Linux to Windows ? 13 51
Samba Question 11 72
I NEED A "BARE" LINUX ... 9 56
This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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.

790 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