Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Perl Programming Language

Computer List (Pls hlp!)


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

SimonH <s@bigpond.net.au> wrote in comp.lang.perl.misc:

> 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

"SimonH" <s@bigpond.net.au> wrote in message

news:st88i.7674$wH4.5892@news-server.bigpond.net.au...
> 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";

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.

<anno4@radom.zrz.tu-berlin.de> wrote in message

news:5ccqhaF306ssnU1@mid.dfncis.de...

Thanks Lambik...much appreciated.

"Lambik" <lam@kieffer.nl> wrote in message

news:46613b6b$0$37711$5fc3050@dreader2.news.tiscali.nl...

>>>>> "A" == anno4000  <anno4@radom.zrz.tu-berlin.de> writes:

    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

--
Charlton Wilbur
cwil@chromatico.net

Very interesting answer Wilbur!

I sense a tone about your answer.

"Charlton Wilbur" <cwil@chromatico.net> wrote in message

news:87ps4e2ysj.fsf@mithril.chromatico.net...

"SimonH" <s@bigpond.net.au> wrote in message

news:st88i.7674$wH4.5892@news-server.bigpond.net.au...

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

Kevin youre a champion!

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

Simon

"Kevin Sproule" <kevinspro@hotmail.com> wrote in message

news:5Bq9i.450069$6P2.307481@newsfe16.phx...

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc