Re: Translate VBScript Which gets Computer Names to Perl

From: tomthumbkop (tomthumbkop.150pfy_at_mail.codecomments.com)
Date: 04/20/04


Date: Tue, 20 Apr 2004 10:03:36 -0500


If the script works in VBScript, why are you trying to translate it?

But what about line 5... I tried objDomain ->filter =
Array("Computer"); and it barfed.
->Try looking at the perldocs. You may have to use LDAP to do this in
Perl. Since what you are trying to do would fit my definition of
Windows Admin scripting, I've never tried doing this sort of thing in
Perl, I would use VBscript.

Also does Perl have an array that
can grow?
->Since Perl arrays are not dimesion constrained, they will always grow
or shrink automatically to be whatever size you wnat them to be. Look
at:
perldoc -f push
perldoc -f pop
perldoc -f shift
perldoc -f unshift

Or should I be even trying to translate this script to Perl?
IMO no.

corn29@ no_spam excite.com wrote:
> *Hello,
>
> Looking for some advice regarding translating this script (or
> tossing
> this script out if there is a better Perl way of doing it) from vbs
> into Perl.
>
> I have a VB script that gets all the names of the computers in a
> given
> domain. I didn't bind to OUs because I want all the computer
> names...
> just not the domain controllers, computers, or any other location
> where they may be hiding.
>
> 1. strWhatDomain = "domain.local"
> 2. Dim arrNameArray()
> 3.
> 4. Set objDomain = getObject("WinNT://" & strWhatDomain)
> 5. objDomain.filter = Array("Computer")
> 6.
> 7. ' Index for computer name array
> 8. intNameCounter = 0
> 9.
> 10. For Each Item In objDomain
> 11.
> 12. ReDim Preserve arrNameArray(intNameCounter)
> 13. arrNameArray(intNameCounter) = Item.Name
> 14.
> 15. ' For Debug
> 16. ' WScript.Echo arrNameArray(intNameCounter) & " " &
> intNameCounter
> 17.
> 18. intNameCounter = intNameCounter + 1
> 19.
> 20. Next
>
> Now I know translating things like lines 1 and 4 is pretty simple.
> But what about line 5... I tried objDomain ->filter =
> Array("Computer"); and it barfed. Also does Perl have an array that
> can grow? Like ReDim for VB or an ArrayList in Java?
>
> Or should I be even trying to translate this script to Perl? Is
> there
> a Perl resource that I haven't found yet that would help be use Perl
> to get all the names of the computers in a domain? When I do a
> search
> engine search on similar strings, I get a lot of results that aren't
> relevant. Refining my search string hasn't been that helpful
> either.
>
> Thanks,
>
> --CW *

--
tomthumbkop
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
 


Relevant Pages