Glave Adams
New member
I have not used perl in over two years and have been just getting back into it for a job at work. I have never run a script long enough to worry about out of memory errors and was wondering how to fix it. The machine has 2GB of RAM and the code that it is executing is as follows.
Named_Array is the array of names of the machines chosen to go through the next process in the script.
my $count = 0;
open my $INFO, q{>}, "Computer System Information.txt";
my @Sys_info;
my $Info_line;
my @Sys_lined_info;
my $count2 = 0;
foreach(@Name_Array){
@Sys_info = `systeminfo /S $Name_Array[$count]`;
foreach(@Sys_info){
if($_ =~ m/OS Name:/ | $_ =~ m/Product ID:/ | $_ =~ m/System Model:/ | $_ =~ m/Total Physical/){
$Sys_lined_info[$count2] = $_;
$count2++;
}
}
$Info_line = "@Sys_lined_info";
$Sys_lined_info[$count] = $Info_line;
$count2 = 0;
$count++;
}
print $INFO " @Sys_lined_info";
This is part of a script that I have been writing the goal here is to use the SYSTEMINFO command to find several pieces of information on machines I previously weeded out using the NET VIEW command. and remove it from the output returned from the command which returns a hundred lines or so of information about each machine.
I dont know if the script actually works, I have only been able to troubleshoot logical syntax errors, this is because I don't yet have the permissions on the network to execute the command on remote machines, I am currently working on achieving that. I would like to make sure it is working as much as possible before I get those however.
I know it executes correctly up to that point, and that when it reaches that part of the code I am prompted to input my password with: Type the password for DOMAIN\USER: I enter my password, it errors due to permissions, then I get asked six time over and it seems to process it even though it errors. however after six I get the memory error. Im assuming its keeping the data from every machine over and over again but I was under the impression the previous machines info gets written over and replaced...
Any advice would be helpful, thanks.
I have removed all debugging for simplicity measures, this code was created yesterday and has since been updated, I believe the problem is solved at the moment.
Named_Array is the array of names of the machines chosen to go through the next process in the script.
my $count = 0;
open my $INFO, q{>}, "Computer System Information.txt";
my @Sys_info;
my $Info_line;
my @Sys_lined_info;
my $count2 = 0;
foreach(@Name_Array){
@Sys_info = `systeminfo /S $Name_Array[$count]`;
foreach(@Sys_info){
if($_ =~ m/OS Name:/ | $_ =~ m/Product ID:/ | $_ =~ m/System Model:/ | $_ =~ m/Total Physical/){
$Sys_lined_info[$count2] = $_;
$count2++;
}
}
$Info_line = "@Sys_lined_info";
$Sys_lined_info[$count] = $Info_line;
$count2 = 0;
$count++;
}
print $INFO " @Sys_lined_info";
This is part of a script that I have been writing the goal here is to use the SYSTEMINFO command to find several pieces of information on machines I previously weeded out using the NET VIEW command. and remove it from the output returned from the command which returns a hundred lines or so of information about each machine.
I dont know if the script actually works, I have only been able to troubleshoot logical syntax errors, this is because I don't yet have the permissions on the network to execute the command on remote machines, I am currently working on achieving that. I would like to make sure it is working as much as possible before I get those however.
I know it executes correctly up to that point, and that when it reaches that part of the code I am prompted to input my password with: Type the password for DOMAIN\USER: I enter my password, it errors due to permissions, then I get asked six time over and it seems to process it even though it errors. however after six I get the memory error. Im assuming its keeping the data from every machine over and over again but I was under the impression the previous machines info gets written over and replaced...
Any advice would be helpful, thanks.
I have removed all debugging for simplicity measures, this code was created yesterday and has since been updated, I believe the problem is solved at the moment.