Hi,
I am running Perl 5.8.9 (I know its old, but thats what installed on the server and I dont have access rights to upgrade) on a Windows 2003 server.
I am trying to write a script to set a variable symcli_connect to a value so that other commands can use that value. the symcli value is used by EMC's Symmtrix array.
Here's the script:
#!/usr/bin/perl
use warnings;
use strict;
print "Choose The Datacenter\n";
print "1. \Primary\n";
print "2. \Secondary\n";
print "Enter 1 or 2:";
$ENV{"SYMCLI_CONNECT"} = "";
our $datacenter=<STDIN>;
if ($datacenter == 1) {
print "\t\t\t***Setting Environment for Primay***\n";
$ENV{"SYMCLI_CONNECT"} = "primary_server";
system ("symcfg list");
}
elsif ($datacenter == 2) {
print "\t\t\t\t***Setting Environment for Secondary***\n";
$ENV{"SYMCLI_CONNECT"} = "secodnary_server";
system ("symcfg list");
}
else {
print "Please enter only 1 or 2 \n";
}
Problem is, if I choose the Primary data center, it sets the symcli value correct. If, I run the script again, it outputs as if its set the secondary_server value, but when I try checking the value of symcli_connect, its still the first one. As a result its not working the way its supposed to.
Looks like the value of $ENV variable is not being passed outside the if loop.
I am a beginner....to Perl and programming as well.
Can someone let me know where I am going wrong ?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.