Page 1 of 1 1
Topic Options
#38375 - 2003-03-26 02:55 AM Problem on UDF involving IP ADDRESS
lpuyod Offline
Fresh Scripter

Registered: 2002-02-05
Posts: 9
Loc: Philippines
My test machine :
KiXtart 2001 4.20
IP Address. . . . . . . . . . . . : 10.0.28.49
Subnet Mask . . . . . . . . . . . : 255.0.0.0
Default Gateway . . . . . . . . . : 10.16.64.1

Problem:
ERROR : array reference out of bounds!
Script: C:\WINNT\iptest3.KIX
Line : 102

code:
function ipmask($ipaddress1, $ipaddress2)
Dim $bit if instr($ipaddress1,'.') or instr($ipaddress2,'.') or len($ipaddress1)<>32 or

len($ipaddress2)<>32
exit 87
endif $ipmask=''
for $bit=1 to 32
$ipmask=$ipmask+(val(substr($ipaddress1,$bit,1)) & val(substr($ipaddress2,$bit,1)))
next
endfunction
function isiniprange($ipaddress,$iprangearray)
Dim $iprange, $networkid, $subnetmask, $bit

if $ipaddress=''
exit 87
endif

$ipaddress=binaryip($ipaddress)

for each $iprange in $iprangearray

if instr($iprange,'/')
$iprange=split($iprange,'/')
$networkid=binaryip($iprange[0])

if instr($iprange[1],'.')
$subnetmask=binaryip($iprange[1])
else
$subnetmask=''
for $bit=1 to val($iprange[1])
$subnetmask=$subnetmask+'1'
next
for $bit=(val($iprange[1])+1) to 32
$subnetmask=$subnetmask+'0'
next
endif

if isinsubnet($ipaddress,$networkid,$subnetmask)
$isiniprange=1
return
else
$isiniprange=0
endif
endif
next
endfunction
DIM $iparray[0]
DIM $iparray[1]
DIM $iparray[2]
$ipaddress=@IPADDRESS0
$iparray[0]='10.0.28.0/24'
$iparray[1]='10.0.40.0/24'
$iparray[2]='10.0.27.0/24
call "isiniprange.udf"
IF isiniprange($ipaddress,$iparray[0])
MessageBox ("Welcome to IRRI",0,35 )
ENDIF
:EXIT
Exit

Also Tried this Code:

$ipaddress=@IPADDRESS0
$iparray[0]='10.0.28.0/24'
$iparray[1]='10.0.28.0/255.255.255.0'
$iparray[2]='10.0.28.49/255.0.0.0'
IF isiniprange($ipaddress,$iparray)
MessageBox ("Welcome to IRRI",0,35 )
ENDIF

{edit}Bullock - Added CODE tags, But the code was not properly indented. Please edit your code use proper indentation to assist in the readablility of your code.

[ 26. March 2003, 12:58: Message edited by: Howard Bullock ]

Top
#38376 - 2003-03-26 06:52 AM Re: Problem on UDF involving IP ADDRESS
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
lpoyud,

May I make a recommendation? Can you post your code between the [CODE]..[/CODE] tags? Use the Code Button below to do so when creating a post.

Anyway, here is what was found..

Ran your code through KiXStrip and see the following:

quote:

$iparray[2]='10.0.27.0/24
; -------> Warning KIXSTRIP: 53 line incomplete "single quotation".
; -------> Warning KIXSTRIP: 53 line incompleted.

KiXStrip can be found here - http://home.wanadoo.nl/scripting/

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#38377 - 2003-03-27 04:07 PM Re: Problem on UDF involving IP ADDRESS
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Also, why do you include the UDF in yoru code and then also CALL the same UDF located in an external file? Please read the FAQ Forum, e.g. How to use UDFs
_________________________
There are two types of vessels, submarines and targets.

Top
#38378 - 2003-03-31 06:02 AM Re: Problem on UDF involving IP ADDRESS
lpuyod Offline
Fresh Scripter

Registered: 2002-02-05
Posts: 9
Loc: Philippines
Thanks For your Reply,
Hi Kdyer and Sealeopard
I tried many variation but still doesn't work.
Do you have a sample working Code for IsinSubnet.UDF and IsInIprange.UDF

here's the result of my Kixstrip420 code:

Kixstrip 4.20 (vs 4.00e) 0.49 (sec)

input 80 iptest3.kix
output 80 test.out (skip: 0 blocks: 0 labels: 1)
block_check block_structures=17 functions=3 labels=1
tab=6 (default)

**********************************

And Test.out
*******************
mon 31-mar-2003 11:56:39 (kix 4.20 vs 4.00e)
;
;Informative KIXSTRIP: no errors found (input=80 output=80 skip=0).
;
;Informative KIXSTRIP: 17 block_structures found.
;Informative KIXSTRIP: 3 UDF's found.
;Informative KIXSTRIP: 1 label found.
;Summary KIXSTRIP: BREAK CALL DEBUG DISPLAY ENDFUNCTION EXECUTE EXIT FUNCTION GET GETS GOSUB GOTO OLExxx PLAY QUIT RETURN RUN SHELL SLEEP THEN USE
;Informative KIXSTRIP: 3 ENDFUNCTION
;Informative KIXSTRIP: 3 EXIT
;Informative KIXSTRIP: 3 FUNCTION
;Informative KIXSTRIP: 1 RETURN

Informative KIXSTRIP: no errors found.
************************************
Basically, I want all our Subnet users 10.0.28.X
run a certain cmd:

Thanks for your precious time.
:)Boyet

Top
#38379 - 2003-03-31 07:02 AM Re: Problem on UDF involving IP ADDRESS
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Can you put your current version also on the board?
greetings.

btw: no errors found doesn't always mean you script works in a correct way.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#38380 - 2003-03-31 10:29 AM Re: Problem on UDF involving IP ADDRESS
lpuyod Offline
Fresh Scripter

Registered: 2002-02-05
Posts: 9
Loc: Philippines
Hi MCA,
I already did on my initial post
KiXtart 2001 4.20
Win2000 Pro SP2
My IP Address
IP Address. . . . . . . . . . . . : 10.0.28.49
Subnet Mask . . . . . . . . . . . : 255.0.0.0
Default Gateway . . . . . . . . . : 10.16.64.1

Thanks
:)Boyet

Top
#38381 - 2003-03-31 05:43 PM Re: Problem on UDF involving IP ADDRESS
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
code:
$ipaddress='10.0.28.49'
$iparray='10.0.0.0/8'
$rc = isiniprange($ipaddress,$iparray)
? $rc

Please read TCP/IP Primer, Part I - IP Addresses to determine the correct IP addresses, network IDs, and subnet masks
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


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

Who's Online
1 registered (mole) and 1300 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.063 seconds in which 0.034 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