Computer List (Pls hlp!)

S

SimonH

Hi guys hope you can help me with a perl script.

We are running multiple platforms - NT and XP.
I have a computer list in computers.txt
Each system has a local administrator account, let's say it is
<computername>\administrator, with password 'password'.

What I need to do is to:
1) Determine if the system is NT or XP
2) If it is NT, then connect by <computername>\administrator, with password
'password', then write a line to an output file called output.txt the status
of the browser service. So the format of the output.txt would be something
like:
<computername>, operatingsystem, servicename, status
3) If it is XP, then connect by <domain1>\simon, with password 'simtest',
then write a line to an output file called output.txt with the same 4
columns as 2).
4) While the script is running, a status of 'connecting to <computername>
would be great.

Any help greatly appreciated.

Simon
 
A

anno4000

SimonH said:
Hi guys hope you can help me with a perl script.

We are running multiple platforms - NT and XP.
I have a computer list in computers.txt
Each system has a local administrator account, let's say it is
<computername>\administrator, with password 'password'.

What I need to do is to:

[specs snipped]

We can help you with a program when you get stuck, but we're not in
the business of writing programs to specification.

Anno
 
L

Lambik

SimonH said:
Hi guys hope you can help me with a perl script.

We are running multiple platforms - NT and XP.
I have a computer list in computers.txt
Each system has a local administrator account, let's say it is
<computername>\administrator, with password 'password'.

What I need to do is to:
1) Determine if the system is NT or XP
You could use WMI. Check
http://www.microsoft.com/technet/scriptcenter/scripts/perl/default.mspx for
examples

use Win32::OLE('in');
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

$computer = "."; #or computername
$objWMIService = Win32::OLE->GetObject
("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection
failed.\n";
$colItems = $objWMIService->ExecQuery
("SELECT * FROM Win32_OperatingSystem","WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);

foreach my $objItem (in $colItems)
{
print "$objItem->{Caption}\n";
}
 
S

SimonH

Anno!
Totally understand.
Will heed your advice and only post when really stuck.
I am new to perl and teaching myself, and just wanted a higher level guru to
throw some pointers down about this topic.

SimonH said:
Hi guys hope you can help me with a perl script.

We are running multiple platforms - NT and XP.
I have a computer list in computers.txt
Each system has a local administrator account, let's say it is
<computername>\administrator, with password 'password'.

What I need to do is to:

[specs snipped]

We can help you with a program when you get stuck, but we're not in
the business of writing programs to specification.

Anno
 
S

SimonH

Thanks Lambik...much appreciated.

Lambik said:
You could use WMI. Check
http://www.microsoft.com/technet/scriptcenter/scripts/perl/default.mspx
for
examples

use Win32::OLE('in');
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

$computer = "."; #or computername
$objWMIService = Win32::OLE->GetObject
("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection
failed.\n";
$colItems = $objWMIService->ExecQuery
("SELECT * FROM Win32_OperatingSystem","WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);

foreach my $objItem (in $colItems)
{
print "$objItem->{Caption}\n";
}
 
C

Charlton Wilbur

A> [specs snipped]

A> We can help you with a program when you get stuck, but we're
A> not in the business of writing programs to specification.

Well, some of us *are*, but as it's a business we expect to get paid
for that.

Charlton
 
S

SimonH

Very interesting answer Wilbur!

I sense a tone about your answer.

Charlton Wilbur said:
A> [specs snipped]

A> We can help you with a program when you get stuck, but we're
A> not in the business of writing programs to specification.

Well, some of us *are*, but as it's a business we expect to get paid
for that.

Charlton
 
K

Kevin Sproule

SimonH said:
Hi guys hope you can help me with a perl script.

We are running multiple platforms - NT and XP.
I have a computer list in computers.txt
Each system has a local administrator account, let's say it is
<computername>\administrator, with password 'password'.

What I need to do is to:
1) Determine if the system is NT or XP
2) If it is NT, then connect by <computername>\administrator, with
password
'password', then write a line to an output file called output.txt the
status
of the browser service. So the format of the output.txt would be something
like:
<computername>, operatingsystem, servicename, status
3) If it is XP, then connect by <domain1>\simon, with password 'simtest',
then write a line to an output file called output.txt with the same 4
columns as 2).
4) While the script is running, a status of 'connecting to <computername>
would be great.

Any help greatly appreciated.

Simon

Simon,

This may get you started:

#!/perl/bin/perl.exe -w

use Win32::Service;

my ($hostName, $serviceName, %status);

my %statusCode = (1 => 'STOPPED', 2 => 'START_PENDING',
3 => 'STOP_PENDING', 4 => 'RUNNING',
5 => 'CONTINUE_PENDING',6 => 'PAUSE_PENDING',
7 => 'PAUSED', 8 => 'ERROR');

$hostName = 't23-kevin'; # server name or IP address
$serviceName = 'w3svc'; # short name of service

Win32::Service::GetStatus($hostName, $serviceName, \%status);

print $statusCode{$status{"CurrentState"}}, "\n";


Test:
C:\pl>perl webcheck.pl
STOPPED

C:\pl>net start w3svc
The World Wide Web Publishing service is starting.
The World Wide Web Publishing service was started successfully.


C:\pl>perl webcheck.pl
RUNNING

C:\pl>


Kevin Sproule
 
S

SimonH

Kevin youre a champion!

THANKS SO MUCH FOR YOUR HELP really appreciate it mate. Thank you!!

Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,145
Latest member
web3PRAgeency
Top