Setting Environment Variables

Discussion in 'Perl' started by Rick Kasten, Jul 7, 2004.

  1. Rick Kasten

    Rick Kasten Guest

    Here's what I need to do:

    1) Write "Password:" to the console
    - I know how to do that
    2) Accept input that is not written back to the console
    - I know how to do that (Term::ReadKey)
    3) Set the PASSWD variable so that when the script exits, my env
    variables now include one called PASSWD that contains the text I typed
    at the "Password:" prompt.
    - what I need help with

    Any assistance? I'm sure this is an easy one...
     
    Rick Kasten, Jul 7, 2004
    #1
    1. Advertising

  2. Rick Kasten wrote:
    > Here's what I need to do:

    [...]
    > 3) Set the PASSWD variable so that when the script exits, my env
    > variables now include one called PASSWD that contains the text I typed
    > at the "Password:" prompt.
    >
    > Any assistance? I'm sure this is an easy one...


    Not exactly easy, more like impossible. See the FAQ
    perldoc -q env:
    I {changed directory, modified my environment} in a perl script. How
    come the change disappeared when I exited the script? How do I get my
    changes to be visible?

    jue
     
    Jürgen Exner, Jul 7, 2004
    #2
    1. Advertising

  3. Rick Kasten

    Howard Guest

    > 3) Set the PASSWD variable so that when the script exits, my env
    > variables now include one called PASSWD that contains the text I typed
    > at the "Password:" prompt.
    > - what I need help with



    Rick, are you setting this in a win32 environment? If so, you can
    use the Win32::Registry to set the variable. The key I've used to set
    variables is:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
    Manager\Environment

    Some sample code is:
    use Win32::Registry;
    $p = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment";
    $HKEY_LOCAL_MACHINE->Open($p, $CurrVer) || die "Open $!";

    And you can either create and set or just set a value.

    key->Create($newkey, name)
    key->SetValue(subkey, type, value)

    Hope this helps.

    Howard
     
    Howard, Jul 7, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?YnNmbDQ0?=
    Replies:
    0
    Views:
    489
    =?Utf-8?B?YnNmbDQ0?=
    May 12, 2004
  2. Steve
    Replies:
    6
    Views:
    24,107
    lightsedge
    May 1, 2007
  3. Ulf Meinhardt
    Replies:
    0
    Views:
    570
    Ulf Meinhardt
    Oct 13, 2004
  4. Leo
    Replies:
    2
    Views:
    3,002
    Gordon Beaton
    Mar 21, 2006
  5. Replies:
    5
    Views:
    670
Loading...

Share This Page