#139988 - 2005-05-19 02:20 PM
IP address range mapping?
|
spectrum48k
Lurker
Registered: 2005-05-19
Posts: 3
|
I'm new to scripting, I'm having problems trying to get machines via 2 IP address ranges to access a server shares. This is the script I'm using, nothing seems to be happening. Any ideas?
IF (@IPADDRESS0)= "172.16.136.*" USE X: /Delete /persistent USE X: "\\apps\CD-Roms" ENDIF
IF (@IPADDRESS0)= "172.16.137.*" USE X: /Delete /persistent USE X: "\\apps\CD-Roms2" ENDIF
|
|
Top
|
|
|
|
#139989 - 2005-05-19 02:57 PM
Re: IP address range mapping?
|
Rory Daniels
Getting the hang of it
Registered: 2003-02-25
Posts: 64
Loc: Bristol, UK
|
The @IPAddress macro brings back blank spaces in place of zeros. Try this:
Code:
If TRIM(SUBSTR(@IPADDRESS0, 1, 3)) + "." + TRIM(SUBSTR(@IPADDRESS0, 5, 3)) + "." + TRIM(SUBSTR(@IPADDRESS0, 9, 3)) = "172.16.2" ? "Matched" Else ? "Not Matched" Endif
|
|
Top
|
|
|
|
#139993 - 2005-05-19 04:12 PM
Re: IP address range mapping?
|
spectrum48k
Lurker
Registered: 2005-05-19
Posts: 3
|
I'm still not having any luck, I feel stupid. I have changed my script to the following
$ipaddress=@IPADDRESS0 $iparray[0]='172.16.136.0/24' $iparray[1]='172.16.137.0/24' if isiniprange($ipaddress,$iparray) use X: "\\apps\CDRoms" endif
My only aim is to get machines on the 172.16.136.x range and 172.16.137.x to use X: "\\apps\CDRoms" .
|
|
Top
|
|
|
|
#139995 - 2005-05-19 04:26 PM
Re: IP address range mapping?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Try this. This assumes that you have one network adapter, or at least that the first adapter enumerated is the one that you are interested in.
Code:
$sMyNetwork=IPDecimal(IPDecimal(EnumIpInfo(0,0)) & IPDecimal(EnumIpInfo(0,1))) Select Case $sMyNetwork='172.16.136.0' OR $sMyNetwork='172.16.137.0' "Will Map X Drive" ? Use X: /delete /persistent use X: "\\apps\CDRoms" If @ERROR "ERROR: Could not map X: ["+@ERROR+"] "+@SERROR+@CRLF EndIf Case "Default" "Will not map X drive" ? EndSelect ; IPDecimal Dotted Quad <-> Network number conversion Function IPDecimal($v) If InStr($v,".") For Each $v In Split($v,".") $IPDecimal=$IPDecimal+Right("00"+DecToHex($v),2) Next $IPDecimal=Val("&"+$IPDecimal) Else ; Convert to hex and zero fill to 32 bit. ; This avoids problems caused by twos complement representation $v=Right("00000000"+DecToHex($v),8) While $v $IPDecimal=$IPDecimal+"."+Execute("Exit &"+Left($v,2)) $v=SubStr($v,3) Loop $IPDecimal=SubStr($IPDecimal,2) EndIf Exit 0 EndFunction
|
|
Top
|
|
|
|
#139996 - 2005-05-19 04:44 PM
Re: IP address range mapping?
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
Quote:
Quote:
my personal favorite and one not in the FAQ
Then add it. You are a mod... how hard can it be?
hard. Since i am not a mod on the FAQ forum
|
|
Top
|
|
|
|
#139998 - 2005-05-19 05:23 PM
Re: IP address range mapping?
|
spectrum48k
Lurker
Registered: 2005-05-19
Posts: 3
|
Thanks Guys, all your help has resolved the problem
|
|
Top
|
|
|
|
#139999 - 2005-05-19 05:30 PM
Re: IP address range mapping?
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4562
Loc: USA
|
Richard...
Shouldn't this... Code:
Case $sMyNetwork='172.16.136.0' OR $sMyNetwork='172.16.136.0' Be this... Code:
Case $sMyNetwork='172.16.136.0' OR $sMyNetwork='172.16.137.0'
|
|
Top
|
|
|
|
#140000 - 2005-05-20 09:36 AM
Re: IP address range mapping?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
Richard...
Shouldn't this... Code: --------------------------------------------------------------------------------
Case $sMyNetwork='172.16.136.0' OR $sMyNetwork='172.16.136.0'
--------------------------------------------------------------------------------
Be this... Code: --------------------------------------------------------------------------------
Case $sMyNetwork='172.16.136.0' OR $sMyNetwork='172.16.137.0'
Yup. There were a couple of typos in there - should be ok now.
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 342 anonymous users online.
|
|
|