PERL on windows accessing variables from a config file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PERL on windows accessing variables from a config file
# 1  
Old 11-10-2010
PERL on windows accessing variables from a config file

Folks,
I'm a perl moron, so please speak very slowly. : )
I'm modifying a build script that starts up an apache server. Now there is a .config file that hardcodes an old webserver path like this c:\oldWebserver. Now I don't want that hardcoded value, rather wish to use an environmental variable and from a .cmd file can access it with this syntax %APACHE_HOME%.
However, I need to be able to retrieve this value inside this .config file and the same syntax doesn't working.
I also tried:
%{APACHE_HOME}
$ENV{APACHE_HOME}
to no avail.
Any thoughts or recommendations?
Thanks!
# 2  
Old 11-10-2010
How are you using this .config file? Usually .config is for shells, which Windows doesn't usually have.
# 3  
Old 11-11-2010
I'm passing in the config file as a param when starting apache.
Like this
%server_dir%\bin\httpsd.exe -e debug -w -f "conf\inputs.conf" -d "."
# 4  
Old 11-12-2010
The env variable may not be what you expect, try this code I found here:
Code:
#!/usr/bin/perl

print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Print Environment</title></head>
<body>
EndOfHTML

foreach $key (sort(keys %ENV)) {
    print "$key = $ENV{$key}<br>\n";
}

print "</body></html>";

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - is it possible to import variables from a config file?

hi, all. I got a question about awk: If I have a lot of awk files for different tasks, but they'll share the same base directory, log setting, action lists, etc., is it possible to import them from a config file, so that I don't have to put them into each awk file? For example, I need a... (8 Replies)
Discussion started by: lan9856
8 Replies

2. Solaris

Accessing Solaris PCI Config Space extended properties

Hi all, Am working on an enhancement to access Solaris PCI Config Space. I got basic pci config space properties like vendor-id using di_node system calls. But i am not able to access the extended configuration space. Can you please suggest an approach to access the pci extended configuration... (0 Replies)
Discussion started by: vijayrajen
0 Replies

3. Hardware

accessing zte zxv10 w300 modem for config

Hi all, I need to configure the zte zxv10 w300 modem, but can't access to it control panel. Seems to hide or mask it IP address. Someone knows howto access or setup a new configuration ? a hard reset maybe ? then looking in a default IP address ? how is this ? Thanks in advance VicK (0 Replies)
Discussion started by: VicK
0 Replies

4. Shell Programming and Scripting

Parse config file and store the values in variables

Hi, I have a config file that has blank, commented lines. I need to escape commented lines, blank lines, parse the remaining lines and store them in variables or array. the config file contains the following lines. # config file # Define Oracle User ORA_USER=abcde ORA_PASS=xyzabc... (8 Replies)
Discussion started by: Lakshmi Chowdam
8 Replies

5. Shell Programming and Scripting

how to access variables in a config file inside a shell script

I'm writing a shell script. I want to put the variables in a separate config files and use those inside my script. e.g. the config file (temp.conf)will have the values like mapping=123 file_name=xyz.txt I want to access these variables in temp.conf(i.e. mapping and file_name) from inside the... (7 Replies)
Discussion started by: badrimohanty
7 Replies

6. Shell Programming and Scripting

Perl config file Help

Hi In My config file i have 12.122.12.111:2000 A host and a port number. To read the config file i have written in a perl script like this my %config; open my $config, '<','config' or die "Failed to read file :$!"; Its running fine in HP-UX but showing error in solaris... (2 Replies)
Discussion started by: Harikrishna
2 Replies

7. Shell Programming and Scripting

Perl config file Help

HI I have a config file (ip.config)that has the following fields with colon as delimeter. yahoo.com:1919 ( host and port number) rediffmail.com:2020 gmail.com:2121 How to read it in a perl script. I need to parse the host and port number in the perl script using split... (6 Replies)
Discussion started by: Harikrishna
6 Replies

8. Shell Programming and Scripting

Accessing Variables from .conf file

I can't figure out how to access variables that are stored in a separate file. Can someone let me in on the secret? Please, and thank you. -Kevin (7 Replies)
Discussion started by: wayne1411
7 Replies

9. Shell Programming and Scripting

How to parse config variables from external file to shell script

How do i use a config.txt to recursively pass a set of variables to a shell script eg my config.txt looks like this : path=c://dataset/set1 v1= a.bin v2= b.bin path=c://dataset/set2 v1= xy.bin v2= abc.bin .................. and so on . and my testscript : (2 Replies)
Discussion started by: pradsh
2 Replies

10. Shell Programming and Scripting

accessing variables declared in another perl script

Hi all, I have a perl script which declares two variables and calls another perl script which accesses those variables. But I am unable to access the variables in the called script. My script is as follows: my $ENV{a}="20"; system("perl called.pl"); and my called.pl contains: print... (3 Replies)
Discussion started by: gurukottur
3 Replies
Login or Register to Ask a Question