Operating System - Microsoft
1748123 Members
3346 Online
108758 Solutions
New Discussion юеВ

How to use a windows variable within perl scripting

 
Junior C.
Frequent Advisor

How to use a windows variable within perl scripting

All,

I have a perl script that need to trigger of an .exe for the following directory.

C:\Documents and Settings\All Users\Application Data\HP\HP BTO Software\bin\instrumentation

On the windows server "set" show the variable is set to OvAgentDir

I try the following none seem to work.

my $INST_DIR = "%OvAgentDir%";
my $INST_DIR = "C:\\DOCUME~1\\ALLUSE~1\\Application Data\\HP\\HP BTO Software";

I appreciate all help.

Thanks,

-Junior
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor

Re: How to use a windows variable within perl scripting

Hi Junior:

How about:

# perl -e "my $INST_DIR='C:\DOCUME~1\ALLUSE~1\Application Data\HP\HP BTO Software';chdir $INST_DIR or print 'no can do'"

Regards!

...JRF...
ghostdog74
Occasional Advisor

Re: How to use a windows variable within perl scripting

you can get windows environment variable using ENV. eg $ENV{'OvAgentDir'}