Re: Problem setting env variable in script

From: Bill Verzal (BVerzal_at_KOMATSUNA.COM)
Date: 11/21/03

  • Next message: Renison, Rick: "Re: script backgrounds itself"
    Date:         Fri, 21 Nov 2003 13:57:59 -0600
    To: aix-l@Princeton.EDU
    
    

    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


  • Next message: Renison, Rick: "Re: script backgrounds itself"

    Relevant Pages

    • Re: Error handling bug on GetObject?
      ... I seem to have hit a bug in the error handling of VBScript. ... If Error Handling is not turned on, then the script crashes on the GetObject ... In a main routine, this code behaves exactly as expected. ...
      (microsoft.public.scripting.vbscript)
    • Re: Error handling bug on GetObject?
      ... I seem to have hit a bug in the error handling of VBScript. ... If Error Handling is not turned on, then the script crashes on the GetObject ... In a main routine, this code behaves exactly as expected. ...
      (microsoft.public.scripting.vbscript)
    • RE: Simple Script??
      ... Well, it is not the most elegant solution I have ever written, but the script ... Since you only needed to copy a file to every profile, ... full directory recursion in the routine. ... will copy a file called File.txt to the Start folder in every profile. ...
      (microsoft.public.windowsxp.security_admin)
    • RE: Simple Script??
      ... I had a typo in the path...Your script is AWESOME THANKS AGAIN!!!! ... Since you only needed to copy a file to every profile, ... full directory recursion in the routine. ... will copy a file called File.txt to the Start folder in every profile. ...
      (microsoft.public.windowsxp.security_admin)
    • RE: Simple Script??
      ... But when i run it the script fails. ... Since you only needed to copy a file to every profile, ... full directory recursion in the routine. ... will copy a file called File.txt to the Start folder in every profile. ...
      (microsoft.public.windowsxp.security_admin)