Hello all,
I beginning in perl and am having an issue here at work trying to get something to work properly.
I use a program called srvinfo.exe to get information about the PC's I am admin on without having to go pc by pc down on the production floor, and server rooms. What i am trying to do is write a script that will run this in command prompt using an input file that has the names of each PC on them, then it outputs to another file the information it ussually prints out to the command prompt window.
Before I go on, here is my code:
#!/usr/local/bin/perl
open (PCINFO, "pcinfo.txt" or die "I could not get at pcinput.txt";
while (<PCINFO>)
{
$srv=$_;
open (SRVINFO, ">>srvinfo.txt" or die "I could not open
srvinfo.txt";
print SRVINFO "srvinfo -ns \\\\$srv";
close SRVINFO;
system "srvinfo -ns \\\\$srv >> srvinfo.txt";
open (SRVINFO, ">>srvinfo.txt" or die "I could not open
srvinfo.txt";
print SRVINFO "\n===========================\n\n";
close SRVINFO;
}
close PCINFO;
So, my input file would look tlike this:
rrc7202-desk
rrc7852
snmhp101
(so on and so forth)
ok, if I only have 1 PC in teh list, it works fine and my output file will look something like this:
srvinfo -ns \\rrc7202-desk
Server Name: rrc7202-desk
Security: Users
Registered Owner: Intel Corporation
Registered Organization: Windows 2000 Single User Network-Centric Bullpen
(A BUNCH MORE INFO WAS HERE, BUT UNFORTUNATELY IT IS INTEL CONFIDENTIAL)
System Up Time: 0 Days, 15 Hr, 25 Min, 41 Sec
===========================
So, that works and is what i am looking for.
Now, if I have more than 1 PC in the list, (lets say 4 C's) It will only append the last PC in the list to teh output file, and the others are output to the command prompt window. The output file looks like this:
srvinfo -ns \\rrc7852
===========================
srvinfo -ns \\snmhp101
===========================
srvinfo -ns \\rrc7202-desk
Server Name: rrc7202-desk
Security: Users
Registered Owner: Intel Corporation
Registered Organization: Windows 2000 Single User Network-Centric Bullpen
(A BUNCH MORE INFO WAS HERE, BUT UNFORTUNATELY IT IS INTEL CONFIDENTIAL)
System Up Time: 0 Days, 15 Hr, 25 Min, 41 Sec
===========================
So, I am thinking that my problemis with the line:
system "srvinfo -ns \\\\$srv >> srvinfo.txt";
Can anyone help me to get it to print EVERYTHING into teh text file and not just the last PC in the list?
Let me know if you need anymore information.
I beginning in perl and am having an issue here at work trying to get something to work properly.
I use a program called srvinfo.exe to get information about the PC's I am admin on without having to go pc by pc down on the production floor, and server rooms. What i am trying to do is write a script that will run this in command prompt using an input file that has the names of each PC on them, then it outputs to another file the information it ussually prints out to the command prompt window.
Before I go on, here is my code:
#!/usr/local/bin/perl
open (PCINFO, "pcinfo.txt" or die "I could not get at pcinput.txt";
while (<PCINFO>)
{
$srv=$_;
open (SRVINFO, ">>srvinfo.txt" or die "I could not open
srvinfo.txt";
print SRVINFO "srvinfo -ns \\\\$srv";
close SRVINFO;
system "srvinfo -ns \\\\$srv >> srvinfo.txt";
open (SRVINFO, ">>srvinfo.txt" or die "I could not open
srvinfo.txt";
print SRVINFO "\n===========================\n\n";
close SRVINFO;
}
close PCINFO;
So, my input file would look tlike this:
rrc7202-desk
rrc7852
snmhp101
(so on and so forth)
ok, if I only have 1 PC in teh list, it works fine and my output file will look something like this:
srvinfo -ns \\rrc7202-desk
Server Name: rrc7202-desk
Security: Users
Registered Owner: Intel Corporation
Registered Organization: Windows 2000 Single User Network-Centric Bullpen
(A BUNCH MORE INFO WAS HERE, BUT UNFORTUNATELY IT IS INTEL CONFIDENTIAL)
System Up Time: 0 Days, 15 Hr, 25 Min, 41 Sec
===========================
So, that works and is what i am looking for.
Now, if I have more than 1 PC in the list, (lets say 4 C's) It will only append the last PC in the list to teh output file, and the others are output to the command prompt window. The output file looks like this:
srvinfo -ns \\rrc7852
===========================
srvinfo -ns \\snmhp101
===========================
srvinfo -ns \\rrc7202-desk
Server Name: rrc7202-desk
Security: Users
Registered Owner: Intel Corporation
Registered Organization: Windows 2000 Single User Network-Centric Bullpen
(A BUNCH MORE INFO WAS HERE, BUT UNFORTUNATELY IT IS INTEL CONFIDENTIAL)
System Up Time: 0 Days, 15 Hr, 25 Min, 41 Sec
===========================
So, I am thinking that my problemis with the line:
system "srvinfo -ns \\\\$srv >> srvinfo.txt";
Can anyone help me to get it to print EVERYTHING into teh text file and not just the last PC in the list?
Let me know if you need anymore information.