Page 2 of 2 <12
Topic Options
#24881 - 2002-07-12 12:14 AM Re: Drive mapping according to server name or IP address?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You have a spelling error, its IF EXIST() and you have an 'S' too much at the end.
_________________________
There are two types of vessels, submarines and targets.

Top
#24882 - 2002-07-12 12:21 AM Re: Drive mapping according to server name or IP address?
Kdyer Offline
KiX Supporter
*****

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

Personally, you should pick this up by group and not a "marker" file..

Note: I have added in some things to think about with this

code:
IF INGROUP ("Accounting")
USE P: "\\gbtacksrv01\apps"
USE S: "\\gbtacksrv01\@userid$$"
ELSE
USE P: "\\gbtsrv01\apps"USE S: "\\gbtsrv01\@userid$$"
ENDIF
IF INGROUP ("Domain Users")
USE S: "\\gbtacksrv01\shared"
USE LPT1: "\\gbtacksrv01\ackmitalj"
endif

One thing to think about with the SELECT..CASE..ENDSELECT statement, it will leave on the first true condition it finds.

{first edit - enclose share point with double quotes}
{second edit - removed /persistent:no with nothing as this would be the same thing}
HTH,

Kent

[ 12 July 2002, 09:38: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#24883 - 2002-07-12 12:37 AM Re: Drive mapping according to server name or IP address?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Dax, by far, the best solutions for your issue are related to the use of the combination of the client's (IP address and subnetmask). The logical subnet on which a client is located is determined by the bitwise "AND" of each octet of the IP and MASK.

So:
IP = 123.12.45.100
MASK = 255.255.255.128

Logical subnet is calculated by performing bitwise operations:
123 & 255 = 123
12 & 255 = 12
45 & 255 = 45
100 & 128 = 0

123.12.45.0 is the logical subnet. Clients with IP addresses 123.12.45.1-127 are located on this subnet based on the mask. Clients 123.12.45.129-254 are located on subnet 123.12.45.128 if they all have a subnet mask listed above.

To find your logical subnets use this UDF and script. Supply some of your clients IP and masks and checkout the result.
code:
$IP = "x.x.x.x"
$SNmask = "y.y.y.y"
? CalcLogicalSubnet ($IP, $SNmask)

Function CalcLogicalSubnet ($IP, $SNmask)
; Version 2.0
; This function calculates the logical subnet for a given IP address and subnet mask.
; The $IP parameter can be padded with spaces as from @IPADDRESS0 or without
; as from EnumIPinfo().
;
; Sets two exit codes that are passed to @Error
; 1 = Improperly formatted IP address
; 2 = Octet out range (0-255)

dim $IP, $SNmask
dim $i ;Counter for looping through 4 octets of the IP and subnet mask
dim $arrayIP ;Holds the string representation of the IP address octets.
dim $arraySN ;Holds the string representation of the subnet mask octet.
dim $Subnet ;Holds the string that becomes the logical subnet.
dim $x, $y ;Holds value of IP and SNmask octet.

$arrayIP = split($IP, ".")
$arraySN = split($SNmask, ".")

If UBound($arrayIP) = 3 and UBound($arraySN) = 3
For $i=0 to 3
$x = Val(LTrim($arrayIP[$i]))
$y = Val(LTrim($arraySN[$i]))
If $x >= 0 and $x < 256 and $y >= 0 and $y < 256
$Subnet = "" + $Subnet + ($x & $y) + "."
Else
Exit(2)
Endif
Next
$CalcLogicalSubnet = substr($Subnet, 1, len($Subnet)-1)
Exit(0)
Else
Exit(1)
Endif
Endfunction


You then could do something like:
code:
if "your logical subnet" = CalcLogicalSubnet ($IP, $SNmask)
do something...
endif

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#24884 - 2002-07-12 12:42 AM Re: Drive mapping according to server name or IP address?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See also the UDFs posted in the third post, they all do nearly the same.

Kyder: Please check your USE syntax for the appropriate amount of quotes!
_________________________
There are two types of vessels, submarines and targets.

Top
#24885 - 2002-07-12 12:47 AM Re: Drive mapping according to server name or IP address?
Kdyer Offline
KiX Supporter
*****

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

Sorry about that..

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

Top
#24886 - 2002-07-12 06:37 AM Re: Drive mapping according to server name or IP address?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Dax,
I mean you no disregard, but I get the feeling you have a fear of UDFs. They are certainly worth taking the time to understand.

I think you are dealing with simple subnetting and don't want the complex calculations that Howard and Jens are proposing. You also haven't divulged what version of KiX you use so some of the code proposed may not be usable.

Don't lose sight of the fact that the @IPAddress0 macro returns a string and as such, < and > compares are not straight forward. Better to use the Val() function to convert each octet and compare on it. These principles can be used in a general application, but I understand you are just talking about a "couple of managers". If I understand you right, you put a cookie on their C: drive which I assume then is a laptop. I don't like cookies. They have a habit of disappearing.

Why could you not just use the computer name (@WKSTA) to control the direction of the script if this IP thingy is too hard a chew?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 2 of 2 <12


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

Who's Online
0 registered and 820 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

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