Retrieving pre-set enviroment variables in DOS not working

G

Girish

I have the following snippet of code running on perl, v5.6.1 built for
MSWin32-x86-multi-thread
on Windows XP platform.


if($ENV{'ATS_SETUP'} ne "")
{
$sendEmail = "yes";
$rootDrive = $ENV{'ATS_INDRIVE'};
$templateRoot = $ENV{'ATS_TEMPLATEROOT'};
$ATSRoot = $ENV{'ATS_ATSOUTDRIVE'};
}

Basically all the mentioned environment variables have been set. Yet
still, the above snippet doesn't work. Why? <Banging head>
 
M

Matija Papec

Girish said:
if($ENV{'ATS_SETUP'} ne "")
{
$sendEmail = "yes";
$rootDrive = $ENV{'ATS_INDRIVE'};
$templateRoot = $ENV{'ATS_TEMPLATEROOT'};
$ATSRoot = $ENV{'ATS_ATSOUTDRIVE'};
}

Basically all the mentioned environment variables have been set. Yet
still, the above snippet doesn't work. Why? <Banging head>

Check for environment within your script,

use Data::Dumper;
print Dumper \%ENV;
 
A

anno4000

Girish said:
I have the following snippet of code running on perl, v5.6.1 built for
MSWin32-x86-multi-thread
on Windows XP platform.


if($ENV{'ATS_SETUP'} ne "")
{
$sendEmail = "yes";
$rootDrive = $ENV{'ATS_INDRIVE'};
$templateRoot = $ENV{'ATS_TEMPLATEROOT'};
$ATSRoot = $ENV{'ATS_ATSOUTDRIVE'};
}

Basically all the mentioned environment variables have been set.

Have been set where? In the process that later starts your script?
Does your script see the values?
Yet
still, the above snippet doesn't work. Why? <Banging head>

"Does not work" is a useless error description. What do you expect
to happen, and what happens instead? There is no way to find out what
goes wrong without that information. Please be specific.

Anno
 
G

Girish

Have been set where? In the process that later starts your script?
Does your script see the values?

In a batch file that calls the script. eg
set ATS_SETUP = "yes";

I even tried setting them from the desktop -> "My Computer" ->
"Settings" -> "Advanced" -> "Enviroment variables"
"Does not work" is a useless error description. What do you expect
to happen, and what happens instead? There is no way to find out what

Simple. :) The value retrieved into
$rootDrive = $ENV{'ATS_INDRIVE'};
$templateRoot = $ENV{'ATS_TEMPLATEROOT'};

etc ( I even commented out the if statement) is null. I expect to see
the same values that I see when I do a set ATS_INDRIVE in the
commandline prompt. :)
 
G

Girish

In a batch file that calls the script. eg
set ATS_SETUP = "yes";

I even tried setting them from the desktop -> "My Computer" ->
"Settings" -> "Advanced" -> "Enviroment variables"


Simple. :) The value retrieved into
$rootDrive = $ENV{'ATS_INDRIVE'};
$templateRoot = $ENV{'ATS_TEMPLATEROOT'};

etc ( I even commented out the if statement) is null. I expect to see
the same values that I see when I do a set ATS_INDRIVE in the
commandline prompt. :)- Hide quoted text -

- Show quoted text -

Never mind. Thanks for the response. Solved the problem. It WAS a
problem with whitespace in the batch script.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top