Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Accessing IIS information

by saprice (Novice)
on Jan 29, 2002 at 03:43 UTC ( #142233=perlquestion: print w/replies, xml ) Need Help??

saprice has asked for the wisdom of the Perl Monks concerning the following question:

I am seeking a way to access information from IIS4 W3SVC service on NT. I have a sample VBS script supplied with IIS that uses Object=GetObject("IIS://servername/w3svc") to get at the the root of the right info, I need somewhere to start with translating this to perl.

Replies are listed 'Best First'.
Re (tilly) 1: Translating VBS to Perl
by tilly (Archbishop) on Jan 29, 2002 at 09:38 UTC
    After the usual obligatory use declaration in Perl, the translation is mostly a question of turning the . method calls in VB to -> in Perl, and then obvious syntax changes (for instance property lookups become hash lookups in Perl, you need semi-colons, etc).

    Post a small snippet of VB you want translated, and quite a few people here should be able to show you exactly what I mean.

Re: Translating VBS to Perl
by screamingeagle (Curate) on Jan 29, 2002 at 04:54 UTC
      Thanks, I'm pretty sure Win32::OLE is what I am after, its just a case of translating how VBS does OLE things into perl that I am getting stuck on... I think I may have to dig around the MS website looking for IIS OLE class descriptions and see if I can find something useful:(
Re: Translating VBS to Perl
by rchiav (Deacon) on Jan 31, 2002 at 16:51 UTC
    What tilly said sums it up pretty good. Win32::OLE is really just a wrapper to get at OLE stuff. Beyond useing it, all the learning is about how OLE works. And like tilly said, the little differences between the Perl - VB syntax.

    Look at this for more info on the IIS provider. What they're actually using is ADSI (Active Directory Services Interface). So you're going to want to read up on that too. I'd personally suggest learning a bit more about OLE and ADSI before you try to do too much. Understanding how all this works will go a long way to making it easier to write this stuff in perl.


      I've managed to solve my problem with the help provided here and working through a similar example from Dave Roth's Win32 Perl Programming. The script must be run on a server that has IIS installed on it I've posted the rough working script below if anyone would like to offer some constructive comments
      use Win32::OLE ('in'); my @servers; my $WebService; my(@servers)=@ARGV if ($ARGV[0]); die "usage is findweb SERVERNAME [,SERVERNAME...]" unless ($servers[0] +); foreach my $Server (@servers){ print "Starting with Server $Server\n"; # Get an IIS COM object for the target machine unless($WebService = Win32::OLE->GetObject( "IIS://$Server/w3svc" +)) { print "Unable to find IIS service on $Server, Skipping\n"; next; } foreach my $webserver (in ($WebService)){ my $WebServer = $WebService->GetObject( "IIsWebServer",$webser +ver->{Name} ) || next; #no webserver available if(($WebServer->Class() ne "IIsWebServer") ) { next; #not a webserver object, hmm, skip } print "Starting Webserver $WebServer->{name}\n" foreach my $vdiroot (in ($WebServer)){ my $VRoot = $WebServer->GetObject( "IIsWebVirtualDir", $vd +iroot->{name} ) || next; #not a virtual directory object, hmm, skip if(($VRoot->Class() ne "IIsWebVirtualDir") ) { next; } foreach my $VSubdir (in ($VRoot)){ if($VSubdir->Class() eq "IIsWebVirtualDir") { print "\tVirtual Web Dir Name=/$VSubdir->{name} Pa +th=$VSubdir->{path}\n"; } elsif($VSubdir->Class() eq "IIsWebDirectory") { print "\tWeb Directory Name=/$VSubdir->{name}\n"; } else { next; #not a webdir or a vwebdir, hmm, skip } } } } print "done with server $Server\n"; }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://142233]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2021-09-22 15:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found