Page 1 of 1 1
Topic Options
#51933 - 2000-10-25 03:09 PM one for Bryce
Julian Offline
Starting to like KiXtart

Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
Hi Bryce,

A while back you sent me a fine piece of code to extract a list of NT computers in a domain based in IP. I needed the script the distribute the SU service to each site and it worked a treat. Thanks very much Bryce . Heres the code just to recap your memory:

code:

break on cls
;--------------------------------------------------------------------------
; This script will create a list of all NT computers ip# that are using DHCP
; and are in your domain. the file global.exe and dhcpcmd.exe is needed
; for this script to work.
;--------------------------------------------------------------------------


$tempfile = "%temp%\kix.tmp"
$outfile = "e:\my_scripts\su\ilford.dat"
$domain = "THOMPSONS"
$subnet = "10.2.0.0"
$DHCPServer = "10.2.0.30"


;--------------------------------------------------------------------------
$cr = chr(13)+chr(10)
$computername = ""
$subnetmask = substr("$subnet",1,instr("$subnet",".0"))
Gosub get_computername

shell '%comspec% /c dhcpcmd $DHCPServer enumclients $subnet | find "$subnetmask" > $tempfile'
$nul = open(1,$tempfile,2)
$data = readline(1)
if exist("$outfile") = 1 del $dumfile endif
$nul = open(2,"$outfile",5)
? "writing $outfile"
do
$DHCPIP = rtrim(substr("$data",instr("$data","$subnetmask"),17))
$data = ltrim(substr("$data",20,len("$data")))
$DHCPcname = rtrim(substr("$data",1,instr("$data"," ")))
select
case instr("$computername","$dhcpcname") <> 0
$nul = writeline(2,"\\$dhcpcname$cr") "."
endselect
$data = readline(1)
until @error <> 0
$nul = close(1)
$nul = close(2)
del $tempfile


Exit

:get_computername
shell '%comspec% /c global "domain Users" "$domain" | find "$" > $tempfile'
$nul = open(1,$tempfile)
$temp = readline(1)
do
$computername = $computername + substr($temp,1,len($temp)-1) + ","
$temp = readline(1)
until @error <> 0
$nul = close(1)
del $tempfile
return


Could this code be modified at all so the outfile would show computer name then IP address next to it. e.g.

Computer name IP Address
\\JULIANS 10.2.0.3

I've tried to have a go myself but to be honest its all a bit too daunting for me. I am getting a little better though at the KIX thing.

Anyway can Bryce or anyone give me a hand at all. Any help much appreciated.

Ju

Top
#51934 - 2000-10-25 03:29 PM Re: one for Bryce
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Ju:

this line

code:

$nul = writeline(2,"\\$dhcpcname$cr") "."

Is what prints to the file (really it does 2 things, prints to the $outfile and puts a '.' on the screen). There are two variables $DHCPName and $DHCPIP, I first wrote that program to print out the UNC using the IP address (\\$dhcpip) But i think you asked for the name instead (\\$dhcpname).

Anyways Modify the WRITELINE() commend on that line to write $DHCPName and $DHCPIP to the $outfile.

Glad I could be of help!
Bryce

Top
#51935 - 2000-10-25 03:59 PM Re: one for Bryce
Julian Offline
Starting to like KiXtart

Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
Nice one Bryce worked like a treat added this line:

code:

$nul = writeline(2,"$dhcpip \\$dhcpcname$cr") "."

Curiously though after I added this line above the do statement:

code:

writeline(2,"IP Address Computer name$cr")

when it wrote to the file it put a 0 after it e.g. test0.dat. Its no bother like, it just seems strange and it still works bloody lovely. Thanks again:

Ju

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 756 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.05 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org