Page 1 of 1 1
Topic Options
#94955 - 2002-10-29 05:44 PM Challenge for Shawn...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
Shawn,

Something to add on to your KixTartMessenger...

How about a script that will list users like a Buddy List and weather they are online or offline?

[Eek!]

Rocco

[ 29. October 2002, 17:45: Message edited by: Rocco Capra ]
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#94956 - 2002-10-29 05:47 PM Re: Challenge for Shawn...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
this does something like that...

you will need a whole series of UDFs to make this work.

code:
break on
call \\a06\logon\udf.kix

dim $namearray[2,1]
$ip1 ="100.151.234.1"
$sn1 ="255.255.255.128"
$iparray=IPRange($ip1,$sn1)

$index=0
for each $ip in $iparray
? "$ip "
if $ip
$hostname=lookup($ip)
if not @error
"$hostname $index"
$namearray[0,$index]=$hostname
$namearray[1,$index]=$ip
$index=$index+1
redim preserve $namearray[2,$index]
else
$p=WSHPing($ip)
if $p[1]=1
"IP Active"
else
"No Reply"
endif
endif
endif
next

redim preserve $namearray[2,$index-1]
:l
for $loop=0 to ubound($namearray,2)
$computer =$namearray[0,$loop]
$ipaddr =$namearray[1,$loop]
$ping =""
$remoteuser=""
if $computer
$p=WSHPing($ipaddr)
$ip=$p[0]
$ping=$p[1]
endif
if $ping=1
$remoteuser=wmiquery("UserName","Win32_ComputerSystem",$computer)
$color="color b+/n"
if exist("\\$computer\C$\Program Files\hotbar")
$=sendmessage(@wksta,"Hotbar on $computer")
endif
endif
if $remoteuser=""
select
case $ip= "0.0.0.0" $remoteuser="unknown" $color="color w/n"
case $ping=-1 $remoteuser="Down" $color="color r+/n"
case 1 $remoteuser="On-line" $color="color g+/n"
endselect
endif
if len($computer)<8 $computer="$computer " endif
if $ip= "0.0.0.0" $ip= "0.0.0.0 " endif
$_=execute("? '$$computer $$ip '$color $$remoteuser color w/n")
next
?
sleep 30
goto l
exit


Function IPRange($sIPaddress,$sNetMask)
Dim $aiStartRange,$aiMaskBits,$aiEndRange[4],$iHostCount,$i
Dim $iOctet1,$iOctet2,$iOctet3,$iOctet4
Dim $tempArray[1]

$iHostCount=1

$aiStartRange=Split($sIPaddress,".")
$aiMaskBits=Split($sNetMask,".")
Redim Preserve $aiStartRange[4]
Redim Preserve $aiMaskBits[4]

For $i = 0 To 3
$aiMaskBits[$i] =Val($aiMaskBits[$i]) & 255
$aiStartRange[$i] =Val($aiStartRange[$i]) & $aiMaskBits[$i]
$aiEndRange[$i] =$aiStartRange[$i]+(255-$aiMaskBits[$i])
$iHostCount =$iHostCount*($aiEndRange[$i]-$aiStartRange[$i]+1)
Next

redim $temparray[$iHostCount]
$i=0
For $iOctet1 = $aiStartRange[0] To $aiEndRange[0]
For $iOctet2 = $aiStartRange[1] To $aiEndRange[1]
For $iOctet3 = $aiStartRange[2] To $aiEndRange[2]
For $iOctet4 = $aiStartRange[3] To $aiEndRange[3]
$temparray[$i]="$iOctet1.$iOctet2.$iOctet3.$iOctet4"
$i=$i+1
Next
Next
Next
Next
$IPRange=$temparray
EndFunction

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#94957 - 2002-10-29 06:02 PM Re: Challenge for Shawn...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
These?...

IPRange($ip1,$sn1)
lookup($ip)
WSHPing($ip)
ubound($namearray,2)
wmiquery("UserName","Win32_ComputerSystem",$computer)

Rocco
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#94958 - 2002-10-29 06:06 PM Re: Challenge for Shawn...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
ubound is built in
also wshpipe()

Don't forget to supply a class C network (IP & subnet) to scan

BTW, remove:
if exist("\\$computer\C$\Program Files\hotbar") $=sendmessage(@wksta,"Hotbar on $computer") endif

as I hijaacked this script to do something else, and hadn't removed it

[ 29. October 2002, 18:07: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#94959 - 2002-10-29 06:40 PM Re: Challenge for Shawn...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
I get this error as soon as it starts...

Script error: expected ']'!
DIM $namearray[2,1]

Rocco
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#94960 - 2002-10-29 07:10 PM Re: Challenge for Shawn...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
what @kix?
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#94961 - 2002-10-29 07:22 PM Re: Challenge for Shawn...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
see new signature... [Big Grin]
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#94962 - 2002-10-29 07:25 PM Re: Challenge for Shawn...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
does 4.10 support 2d arrays?

I'm running 4.12b1 (needed to have COM fixed)
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#94963 - 2002-10-29 07:45 PM Re: Challenge for Shawn...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
Oh I don't know. Prolly not.
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#94964 - 2002-10-29 10:19 PM Re: Challenge for Shawn...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
support for "multidimensional" arrays was added in 4.11 beta 1

anyway, when constructed differently, you can use 2d arrays with older 4.xx kix'es...
_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
0 registered and 823 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.058 seconds in which 0.025 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