By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,869 Members | 1,742 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,869 IT Pros & Developers. It's quick & easy.

Setting Environment Variables

P: n/a
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...
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Jul 19 '05 #2

P: n/a
> 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\Contro l\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
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.