Re: Problem setting env variable in script

From: Bill Verzal (BVerzal@KOMATSUNA.COM)
Date: Fri Nov 21 2003 - 14:57:59 EST


Even though you are exporting the variable, once the script exits, the
value will be erased because it is not passed back "up" the process tree.

If you run the script with a ".", it will perform as you expect.

# . ./setenv

(assuming your script is called "setenv"). Notice the dot/space/dot/slash

BV
--------------------------------------------------------

"If everything is coming your way, then you are in the wrong lane"

Bill Verzal
AIX Administrator, Komatsu America
(847) 970-3726 - direct
(847) 970-4184 - fax

|---------+---------------------------->
| | "Bright, Frank" |
| | <FBright@UARTS.ED|
| | U> |
| | Sent by: IBM AIX |
| | Discussion List |
| | <aix-l@Princeton.|
| | EDU> |
| | |
| | |
| | 11/21/2003 01:33 |
| | PM |
| | Please respond to|
| | IBM AIX |
| | Discussion List |
|---------+---------------------------->
>------------------------------------------------------------------------------------------------------------------------|
  | |
  | To: aix-l@Princeton.EDU |
  | cc: |
  | Subject: Problem setting env variable in script |
>------------------------------------------------------------------------------------------------------------------------|

Hi,

Hopefully this is a quick question. I wrote a script to set an enviornment
variable based on the $USER value. The routine does not set the variable.
Below is the case statement we are using. What is going wrong that it
would not set the env variable ALLOW_AE_UDT in this routine? What is wrong
that if I add the line to set the env var at the end it still will not
work.

I am using the Korn Shell on AIX 5.2.

Thanks in Advance!!

Frank
fbright@uarts.edu

#!/usr/bin/ksh

# Trap common interrupts

#

case $USER in

#

        frank)

                echo 'Set to frank';

                ALLOW_AE_UDT=NONE;

                export ALLOW_AE_UDT;;

        *)

                echo 'Set to all other users'

                export ALLOW_AE_UDT=ALL;;

esac

----------------------------------------------------------------------------

------------
Frank M. Bright, Jr.
Administrative Computing fbright@uarts.edu
University of the Arts (A15) www.uarts.edu
<http://www.uarts.edu/>
320 S. Broad St. 215-717-6081(w)
Philadelphia, PA 19102 215-717-6087(f)
Colleague 17.0.14 AIX 5.2.0.1 Unidata 6.03



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:22 EDT