Page 1 of 2 12>
Topic Options
#39493 - 2003-04-24 02:23 PM IsInIPRange Function
anthonyalderson Offline
Getting the hang of it

Registered: 2003-03-20
Posts: 52
Loc: England
hi everyone, i'm new to kixtart and i'd like to ask a few questions if anyone would be so kind to answer, i've recently been creating a script to define default printers across a network of 18 remote centres, thing is i'm new to all this and the function i'd like to use i dont understand, the function is the isiniprange one, i dont understand how the dependencies work and what i need to do to create the script so that it'll check the local machines ip address against that defined in the array of said function, anyway thats quite a lot to read so i'll leave it with you guys if you dont mind, thanks for any help you might be able to give me guys,

Anth

Top
#39494 - 2003-04-24 02:32 PM Re: IsInIPRange Function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
heh, don't worry...
I've been checking and reading it many times and have not understood it by this date! [Big Grin]
_________________________
!

download KiXnet

Top
#39495 - 2003-04-24 03:02 PM Re: IsInIPRange Function
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
That's a first, Jooel admitting that he doesn't get a UDF. Maybe we should convert it into the next KiXGolf challenge? Make IsInIPRange smaller and remove the dependencies? [Big Grin]

Anyway, I think the UDF is straight-forward. However, I also wrote it [Wink]

First of all, please read TCP/IP Primer, Part I - IP Addresses to refresh your TCP/IP network knowledge.

Secondly, you'll need to include IsInIPRange and it's two dependiencies in your script as e.g. described in How to use UDFs .

Finally, you feed the IP address and an array of networkIDs/subnets into the UDF and you will get a return statement indicating whether the IP address is part of the network. Please implement the example provided in the function header to see how it works.
_________________________
There are two types of vessels, submarines and targets.

Top
#39496 - 2003-04-25 11:10 AM Re: IsInIPRange Function
anthonyalderson Offline
Getting the hang of it

Registered: 2003-03-20
Posts: 52
Loc: England
thanks guys, you've given me a bit of insight into kix, and i feel a little more confident now, and now i'm just gonna have to play about with my script and include the necessary functions (of which i wasnt sure i had to do before), so many thanks guys and if i ever see you out sometime just tap me on the shoulder and i'll buy you a drink.

Anth

Top
#39497 - 2003-04-25 11:26 AM Re: IsInIPRange Function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mm...
what drink?
scotch?
_________________________
!

download KiXnet

Top
#39498 - 2003-04-26 12:12 AM Re: IsInIPRange Function
anthonyalderson Offline
Getting the hang of it

Registered: 2003-03-20
Posts: 52
Loc: England
yeah will a double do?
Top
#39499 - 2003-04-26 12:13 AM Re: IsInIPRange Function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
that sounds nice...

even almost worth to travel to england for just that drink [Wink]
_________________________
!

download KiXnet

Top
#39500 - 2003-04-25 02:45 PM Re: IsInIPRange Function
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
No rocks for me, please [Smile]
_________________________
There are two types of vessels, submarines and targets.

Top
#39501 - 2003-04-25 03:08 PM Re: IsInIPRange Function
anthonyalderson Offline
Getting the hang of it

Registered: 2003-03-20
Posts: 52
Loc: England
okay guys i think i'm getting there, but could you have a look at this and tell me where i'm going wrong please, oh and dont worry about ice lads, i'll buy you a bottle of glenfiddich each for helping me out,

; DEFAULTPRINTER
; To retrieve local machines IP address and cross reference it against a set of defined subnets
;
; AUTHOR Anthony Alderson

CALL "binaryip.kix"
CALL "ipmask.kix"
CALL "isinsubnet.kix"
CALL "isiniprange.kix"

$ipaddress='@IPADDRESS0'
$iparray[0]='192.168. 12. 0/255.255.255. 0' ;ragworth

IF $ipaddress=$iparray[0]
? "you stink"
sleep 3
ELSE
? "guess you dont stink after all"
sleep 3
ENDIF

Top
#39502 - 2003-04-25 03:18 PM Re: IsInIPRange Function
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
drinks ! oh boy, can I help too ?
Top
#39503 - 2003-04-25 03:19 PM Re: IsInIPRange Function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, from the function example I can tell:


; DEFAULTPRINTER
; To retrieve local machines IP address and cross reference it against a set of defined subnets
;
; AUTHOR Anthony Alderson
;modified 25.4.2003 by Lonk
 
CALL "isiniprange.kix"
;and it's requirements:
CALL "binaryip.kix"
CALL "ipmask.kix"
CALL "isinsubnet.kix"
 
if isiniprange('@IPADDRESS0','192.168. 12. 0/255.255.255. 0';ragworth
"you stink"
ELSE
"guess you dont stink after all"
ENDIF
sleep 3



[ 25. April 2003, 15:28: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#39504 - 2003-04-25 03:25 PM Re: IsInIPRange Function
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The CALLs to the UDFs are too optimistic. You should also combine them into one file and use a UDF extension.

CALL "binaryip.kix"
CALL "ipmask.kix"
CALL "isinsubnet.kix"
CALL "isiniprange.kix"

Could become:
CALL @ScriptDir+'\IPLibrary.udf'
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#39505 - 2003-04-25 03:28 PM Re: IsInIPRange Function
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Hmm, there's a reason why there's an example part in the function header [Smile]

And I believe it should also handle the spaces in the IP addresses, too.
_________________________
There are two types of vessels, submarines and targets.

Top
#39506 - 2003-04-25 03:30 PM Re: IsInIPRange Function
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
BOOOOZE !!!! [Eek!] [Eek!] [Eek!]

whats your problems ? [Big Grin]
_________________________



Top
#39507 - 2003-04-25 03:33 PM Re: IsInIPRange Function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sorry Jpo, I got here first [Razz]
_________________________
!

download KiXnet

Top
#39508 - 2003-04-25 03:34 PM Re: IsInIPRange Function
anthonyalderson Offline
Getting the hang of it

Registered: 2003-03-20
Posts: 52
Loc: England
thanks lonkero, i've tried your revised script but it doesnt work at present, simply telling me it expects an expression in line 13 which is the 'if isiniprange.......'

not sure why its doing as i'm inexperienced at this but shouldnt i split up my @ipaddress0 and the range i'm looking in somehow. oh and i've drunk half the bottle lads so we need quicker responses lol, but cheers all of you anyway for helping me out,
Anth

Top
#39509 - 2003-04-25 03:37 PM Re: IsInIPRange Function
anthonyalderson Offline
Getting the hang of it

Registered: 2003-03-20
Posts: 52
Loc: England
yeah jens i saw that, so if i try it using your example and calling in the outside udf's at the start you think i could tweak it to set the printer up, oh and by the way you're so bloody vague with your replies i can hardly see them on screen lol,

cheers,

Anth

Top
#39510 - 2003-04-25 03:40 PM Re: IsInIPRange Function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
anthony, make sure the calling lines are proper.
I might suggest you do:
code:
CALL @scriptdir+"\isiniprange.kix"
;and it's requirements:
CALL @scriptdir+"\binaryip.kix"
CALL @scriptdir+"\ipmask.kix"
CALL @scriptdir+"\isinsubnet.kix"

in this situation if script run during logon, they have to be in the same dir as logonscript.

the expression error suggests right that, the load has failed.
_________________________
!

download KiXnet

Top
#39511 - 2003-04-25 03:41 PM Re: IsInIPRange Function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeah, the b00ze...
no worries man, I have vodka waiting at home [Big Grin]
_________________________
!

download KiXnet

Top
#39512 - 2003-04-25 03:42 PM Re: IsInIPRange Function
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Since you're only checking for a single subnet, the IsInSubnet() should suffice. IsInIPRage is for cases where you have to check for one of many subnets. We e.g. have three separate subnets for VPN connections.
code:
$ipaddress=@IPADDRESS0
$subnet='192.168.12.0/255.255.255.0'
; or
; $subnet='192.168.12.0/24'
if IsInSubnet($ipaddress,$subnet)
; is in subnet
else
; sorry
endif



[ 25. April 2003, 15:42: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 2 12>


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

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.076 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

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