M
mike
Hi,
I have declared my %Properties but I get the following when I execute:
Global symbol "%Properties" requires explicit package name at test.pl
line 62.
Global symbol "%Properties" requires explicit package name at test.pl
line 67.
Global symbol "%Properties" requires explicit package name at test.pl
line 69.
Global symbol "%Properties" requires explicit package name at test.pl
line 71.
Global symbol "%Properties" requires explicit package name at test.pl
line 72.
Global symbol "%Properties" requires explicit package name at test.pl
line 73.
I have noted the lines in the code below.
Do I have to make some declaration within the sub?
cheers,
//mike
***********************************************************************************************
use strict;
use warnings;
my $verbose = 0;
my $info = "[INFO] :";
my $error = "[ERROR]:";
my $configFile;
####################### Subroutines #######################
sub useage (){
print "Useage: perl rdeploy [ -file <config.dat path> ]\n";
exit 1;
}
sub readConfig {
print "Reading configuration data ...\n";
open FILE, "$configFile" or die "$error Could not open file
$configFile:$! ";
my %props = ();
while (<FILE>) {
s/\s+$//;# Remove all \r, \n, ^M from end of line
next if (/^$/);# ignore null lines
next if (/^\s*#/); # ignore comment line.
my ($config_name,$config_val)=split(/\s*=\s*/, $_,2);# Split the
line
$props{$config_name}=$config_val;
$verbose && print "$config_name\n";
}
close FILE;
return %props;
}
sub deploy {
my ($domain,$ear,$port) = @_;
#exit 1;
print "Make sure sailfin is started ...\n";
62: my @startargs = ($Properties{asadminexecutable},
'start-domain',
$domain);
system(@startargs) == 0 or die "system @startargs failed: $?";
67rint "Deploying $ear on $domain on HOST: $Properties{host} ....
\n";
69:my @deployargs = ($Properties{asadminexecutable},
'deploy',
71: "--user=$Properties{user}",
72: "--passwordfile=$Properties{passwordfile}",
73: "--host=$Properties{host}",
"--port=$port",
"$ear");
system(@deployargs) == 0 or die "system @deployargs failed: $?";
if ($? == -1) {
print "failed to execute: $!\n";
}
elsif ($? & 127) {
printf "child died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
}
else {
printf "child exited with value %d\n", $? >> 8;
}
}
#################################### Start Main
#######################################
# Checking arguments #
my $arg = @ARGV;
if ($arg > 0){
if($ARGV[0] =~ /-file/i){
$configFile=$ARGV[1];
}else{
&useage();
}
}else{
print "Using default config.dat in current in same directory as this
script!\n";
$configFile="config.dat";
}
my %Properties = &readConfig();
#Check that password file exists
print "Checking for passwordfile ...\n";
my $file = $Properties{passwordfile};
if(! -f $file ){
print "$error password file, $file, does not exist!";
exit 1;
}
#Deploy on both domains
deploy($Properties{domain1},$Properties{port1},
$Properties{frontenddeployunit});
deploy($Properties{domain2},$Properties{port2},
$Properties{backenddeployunit});
I have declared my %Properties but I get the following when I execute:
Global symbol "%Properties" requires explicit package name at test.pl
line 62.
Global symbol "%Properties" requires explicit package name at test.pl
line 67.
Global symbol "%Properties" requires explicit package name at test.pl
line 69.
Global symbol "%Properties" requires explicit package name at test.pl
line 71.
Global symbol "%Properties" requires explicit package name at test.pl
line 72.
Global symbol "%Properties" requires explicit package name at test.pl
line 73.
I have noted the lines in the code below.
Do I have to make some declaration within the sub?
cheers,
//mike
***********************************************************************************************
use strict;
use warnings;
my $verbose = 0;
my $info = "[INFO] :";
my $error = "[ERROR]:";
my $configFile;
####################### Subroutines #######################
sub useage (){
print "Useage: perl rdeploy [ -file <config.dat path> ]\n";
exit 1;
}
sub readConfig {
print "Reading configuration data ...\n";
open FILE, "$configFile" or die "$error Could not open file
$configFile:$! ";
my %props = ();
while (<FILE>) {
s/\s+$//;# Remove all \r, \n, ^M from end of line
next if (/^$/);# ignore null lines
next if (/^\s*#/); # ignore comment line.
my ($config_name,$config_val)=split(/\s*=\s*/, $_,2);# Split the
line
$props{$config_name}=$config_val;
$verbose && print "$config_name\n";
}
close FILE;
return %props;
}
sub deploy {
my ($domain,$ear,$port) = @_;
#exit 1;
print "Make sure sailfin is started ...\n";
62: my @startargs = ($Properties{asadminexecutable},
'start-domain',
$domain);
system(@startargs) == 0 or die "system @startargs failed: $?";
67rint "Deploying $ear on $domain on HOST: $Properties{host} ....
\n";
69:my @deployargs = ($Properties{asadminexecutable},
'deploy',
71: "--user=$Properties{user}",
72: "--passwordfile=$Properties{passwordfile}",
73: "--host=$Properties{host}",
"--port=$port",
"$ear");
system(@deployargs) == 0 or die "system @deployargs failed: $?";
if ($? == -1) {
print "failed to execute: $!\n";
}
elsif ($? & 127) {
printf "child died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
}
else {
printf "child exited with value %d\n", $? >> 8;
}
}
#################################### Start Main
#######################################
# Checking arguments #
my $arg = @ARGV;
if ($arg > 0){
if($ARGV[0] =~ /-file/i){
$configFile=$ARGV[1];
}else{
&useage();
}
}else{
print "Using default config.dat in current in same directory as this
script!\n";
$configFile="config.dat";
}
my %Properties = &readConfig();
#Check that password file exists
print "Checking for passwordfile ...\n";
my $file = $Properties{passwordfile};
if(! -f $file ){
print "$error password file, $file, does not exist!";
exit 1;
}
#Deploy on both domains
deploy($Properties{domain1},$Properties{port1},
$Properties{frontenddeployunit});
deploy($Properties{domain2},$Properties{port2},
$Properties{backenddeployunit});