Page 1 of 1 1
Topic Options
#116746 - 2004-03-24 06:00 PM Looking for 3 letters in the hostname
Shaggydog Offline
Fresh Scripter

Registered: 2003-05-20
Posts: 31
Loc: Mississauga, ON
Hi,
The code I'm working on will check to see if the word MOB appears in the hostname. ie: WMOB1 or TYMOB2 etc...

So far this is what I've done.

$mobile=(@substr(@wksta,-4,3)

My understanding of the syntax may be my error.
I believe that the -4 means it's 4 characters from the back and then 3 characters long.

Would it be so simple as to just do this though?

$mobile=@wksta
if $mobile="*MOB*"
blah blah blah
end if

?
Thanks in advance for your help

Top
#116747 - 2004-03-24 06:05 PM Re: Looking for 3 letters in the hostname
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
If InStr(@WKSTA,"MOB")
...do your stuff
EndIf

Top
#116748 - 2004-03-24 06:06 PM Re: Looking for 3 letters in the hostname
Shaggydog Offline
Fresh Scripter

Registered: 2003-05-20
Posts: 31
Loc: Mississauga, ON
Thanks, I'll try it.

I appreciate how quick you responded.

Top
#116749 - 2004-03-24 06:08 PM Re: Looking for 3 letters in the hostname
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I should also point out that SubStr() doesn't support negative indexes.

I wrote an enhanced SubStr() a while back which does support negative indexes and lengths - search the UDF forum for it if you think it would be useful.

Top
#116750 - 2004-03-24 06:27 PM Re: Looking for 3 letters in the hostname
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You should also read the KiXtart Manual as it descibes the SUBSTR() syntax. It states specifically that the second parameter is number of characters from the left! Also, what is the lone @ doing in front of SUBSTR?
_________________________
There are two types of vessels, submarines and targets.

Top
#116751 - 2004-03-31 05:33 PM One last thing
Shaggydog Offline
Fresh Scripter

Registered: 2003-05-20
Posts: 31
Loc: Mississauga, ON
Thanks for your help. The other complication I've run across is the step I was hoping to do in the If statement.

i want to map drives by IP, but I've discovered that by looking at the manual that the "use" doesn't do this.

I've tried a search, but it didn't clear up the issue.

Any UDF's that I could use for this?

Thanks

Top
#116752 - 2004-03-31 07:37 PM Re: One last thing
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See the FAQ Forum, it has a TCP/IP Primer.
_________________________
There are two types of vessels, submarines and targets.

Top
#116753 - 2004-03-31 09:20 PM Mapping Drives by IP
Shaggydog Offline
Fresh Scripter

Registered: 2003-05-20
Posts: 31
Loc: Mississauga, ON
Thanks.

I'm still struggling to get this to work properly, but I'm imaging that I must've missed a step.

There wasn't anything in that primer that mapped drives by IP, but i saw how ip information can be held in variables.

I tried this.

$ip='192.168.1.1'
use F: "\\$ip\Users"

At this point it hasn't worked. I figure I'm doing something fundamentally wrong.


Top
#116754 - 2004-03-31 09:44 PM Re: Mapping Drives by IP
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Can I ask a silly question? Why are you mapping a drive to the same client?

Anyway, here is the code..
Code:

CLS
BREAK ON
$1st=TRIM(SPLIT(@IPADDRESS0,'.')[0])
$2nd=TRIM(SPLIT(@IPADDRESS0,'.')[1])
$3rd=TRIM(SPLIT(@IPADDRESS0,'.')[2])
$4th=TRIM(SPLIT(@IPADDRESS0,'.')[3])
?$1st
?$2nd
?$3rd
?$4th

IF $1st+'.'+$2nd = '192.168'
use F: '\\'+ $1st+'.'+$2nd+'.'+$3rd+'.'+$4th+'\Users'
ENDIF

?
?'Press a key..'
GET $k


HTH,

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

Top
#116755 - 2004-03-31 09:48 PM Re: Mapping Drives by IP
Shaggydog Offline
Fresh Scripter

Registered: 2003-05-20
Posts: 31
Loc: Mississauga, ON
I'm not trying to map to a folder on the same client.

I'm trying to map to a folder on the server, but when our laptops connect via VPN we can't reach drive mappings created by using host name.

Use F: "\\server\share" works fine when connected by through the VPN it fails.

The server IP is 192.168.1.100, and I know windows can do drive mapping this way, I'd like to set it up using the script.

Top
#116756 - 2004-03-31 09:50 PM Re: Mapping Drives by IP
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I'm not sure what you've read but the third part of the primer contains a list of UDFs related to IP addresses, one of them is used to identify whether an IP is part of a specific subnet, which would be the way you'd decide whether an IP address would get a printer.
_________________________
There are two types of vessels, submarines and targets.

Top
#116757 - 2004-03-31 10:16 PM Re: Mapping Drives by IP
Shaggydog Offline
Fresh Scripter

Registered: 2003-05-20
Posts: 31
Loc: Mississauga, ON
I'm not trying to decide which IP gets what printer.

I am trying to create drive maps using the IP instead of the host name. use F: "\\server\share" replaced with something that effectively does this.
Use F: "\\192.168.1.100\share"

Across our VPN drive maps created using hostnames do not work. Drive maps created using IP's do.

I already know the exact IP's i would like to map.

Top
#116758 - 2004-03-31 10:39 PM Re: Mapping Drives by IP
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Then what is the problem with
Code:

Use F: "\\192.168.1.100\share"
? 'Error '+@ERROR+' - '+@SERROR



Also, if your VPN clients cannot look up computers based on hostnames, then you will need to properly configure your network by using DNS/WINS or a HOSTS file.
_________________________
There are two types of vessels, submarines and targets.

Top
#116759 - 2004-04-01 11:10 AM Re: Mapping Drives by IP
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
What are the clients?

I have vague memories that the network redirector on older clients does not support IP addresses.

As you are using a VPN I assume that you cannot use WINS or DNS because that is set for the ISP that you have dialled into.

In this case Jens' other suggestion is your best bet.

When your script starts, update the local HOSTS and/or LMHOSTS with all the IP addresses that your client will need for the session. Include the DOMAIN information for LMHOSTS entries where appropriate. You may need to force a reload of the files.

Do this *before* you attempt any TCP or NetBIOS type connections to your netowrk, otherwise you may cache a negative response.

Of course, the client also needs to be configured to use the static address files...

Top
#116760 - 2004-04-01 04:38 PM Re: Mapping Drives by IP
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Correctly configured VPNs will be able to use the company's DNS/WINS infrastructure.
_________________________
There are two types of vessels, submarines and targets.

Top
#116761 - 2004-04-01 05:05 PM Re: Mapping Drives by IP
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Some rambling thoughts...

When you are running VPN over the Internet, you have two possible sources for DNS, the ISPs DNS and your own internal corporate DNS server.

Now, in the "Advanced" tab of the TCP/IP properties you may add a number of DNS servers.

If you have two different server addresses and the first responds with an authoratitave NXDOMAIN because the address is invalid, does it use the next server? Or are the additional servers used only as backup in case the primary server does not respond?

Usually, you can only have one DNS server responding, and you need to make a decision whether that is the ISP's DNS server, or your internal DNS server. Either way the other may be inaccessible.

To get around this, your internal DNS server is normally configured to forward lookup requests for domains that it does not manage to an external DNS server.

If your VPN connection software promotes your internal DNS server when you make a connection (and drops it out again afterwards) and you have DNS forwarding configured on the internal server then it should all work fine.

If your internal DNS server doesn't forward requests then it is more problematical.

You don't want your internal name server as the primary when your VPN is inactive as name resolution will try to use it.

WINS is not such a problem, as you are likely to only ever need your own internal WINS server.

Top
#116762 - 2004-04-01 06:06 PM Re: Mapping Drives by IP
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
What VPN are you using?

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

Top
#116763 - 2004-04-01 06:44 PM Re: Mapping Drives by IP
Shaggydog Offline
Fresh Scripter

Registered: 2003-05-20
Posts: 31
Loc: Mississauga, ON
Our VPN is set up using Cisco routers across the different connections. My laptop here on the LAN itself has no problem with it's mapped drives and of course creating new ones weither by IP or hostname. When I take it home and use the cisco utility to connect to our work VPN, all the drive mappings I've created here at work, work fine when, but if I try to create new ones I need to do so by IP.

At any rate guys, I took this issue back to my General Manager and pointed out to him that no one aside from me and a few others will be drive mapping while at home anyways.

Jens, Kdyer and Richard, thanks for your patience and great advice. I apologize for monopolizing any time.


Top
#116764 - 2004-04-01 08:53 PM Re: Mapping Drives by IP
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
You have to do it by IP because you have not entered a valid WINS Server or DNS records for the connection.

Connections can have different settings per device.
We run Cisco VPN as well and with my DNS entries I can map based on short names no problem.

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
0 registered and 519 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.075 seconds in which 0.028 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