Page 1 of 2 12>
Topic Options
#71259 - 2002-10-30 03:23 AM Copying a file to a range of computers
dbeiser Offline
Fresh Scripter

Registered: 2001-03-22
Posts: 34
Loc: Melbourne, FL, USA
I looked hi and low but haven't found anything that quite fits my needs. This should be a snap for the masters out there in Kixtart land.

I need to deploy a different version of a hosts. file to various ranges of NT4 computers based on names. I'm running Kix32 ver. 4.11.

My naming convention is as follows (I've masked the first part of the name with xxxxx):

xxxxxE1 - xxxxxE100 (East Floor)
xxxxxM1 - xxxxxM400 (Main Floor)
xxxxxW1 - xxxxxW200 (West Floor)

Depending on which range of the name falls in I need to copy a particular hosts. file to the PC.

The sofware we are running points to a particular application server via a hostname/IP entry in the hosts. file. Problem is that only 64 users can connect to a particular application server (license limit on the app) so I have to split them up between 3 application servers, hence the alternate hosts. files.

Thanks,

Dave
_________________________
Dave Melbourne, FL

Top
#71260 - 2002-10-30 03:39 AM Re: Copying a file to a range of computers
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well you don't really say what you found and what doesn't fit your needs. There are lots of examples of scripts to copy HOSTS files.

You also don't say what OS. NT/2K/XP have perms issues. {edit} OK so I need new glasses... NT4 you say.

If it's the bit about dividing the computer names into groups then that's easy enough.

So fill us in... show us what code you've got and where you need help.

[ 30. October 2002, 03:40: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#71261 - 2002-10-30 04:11 AM Re: Copying a file to a range of computers
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Do you have DNS implemented? Can you configure the clients to use different names for the application servers? If you have DNS and can not use different names, then you could setup a DNS round robin for a single name. This would return a different IP address for each DNS query of the application name.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#71262 - 2002-10-30 04:15 AM Re: Copying a file to a range of computers
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
EH! I was thinking the same thing. Was just brushing up on my DNS stuff for AD so that RR stuff is still fresh in my mind.

Then I got to thinking... "can you do that in NT4 or any other (nix/nux) DNS?" and decided not to go there.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#71263 - 2002-10-30 05:08 AM Re: Copying a file to a range of computers
dbeiser Offline
Fresh Scripter

Registered: 2001-03-22
Posts: 34
Loc: Melbourne, FL, USA
As mentioned above, all workstations are WinNT4 running on an NT4 domain (pdc, bdc).
The server the the workstations need to point to are license servers for the application.

DNS won't work because each license server is limited to 64 clients, that's the limit of the license file. Don't ask me why, but I have to work with it. This means that I have to manually allocate 64 machines to each License server via the the following hosts file entry:

mshost xxx.xxx.xxx.xxx

The kicker is that the name "mshost" is hard coded into the application and must be the same in each hosts file with a differenct IP address for each group of 64 workstations in order to manually point them to one of three license servers.

I haven't tried to code anything because I don't really have a clue where to start.

I hope this fills in the gaps, thanks.
_________________________
Dave Melbourne, FL

Top
#71264 - 2002-10-30 05:36 AM Re: Copying a file to a range of computers
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Well the DNS approach is still valid. The round robin delivery will automatically load balance the license servers.

Do the users have "Administrator" permissions on the NT computers?

Do you have a single account that has "Administrator" permission on ALL computers?

If you do then here is an "Admin" script(Not Tested):
code:
; Requires ADSI

$oDomain = GetObject(WinNT://$DomainName")
$oDomain.filter="computer",""
For Each $Computer in $oDomain
$ComputerName = $Computer.name
Select
Case Substr($ComputerName, 6, 1) = "E" $File = "HostFile1"
Case Substr($ComputerName, 6, 1) = "M" $File = "HostFile2"
Case Substr($ComputerName, 6, 1) = "W" $File = "HostFile3"
Case 1 $File = ""
Endselect

If $File <> ""
copy "\\Server\share\" + $File "\\" + $ComputerName + "\Admin$$\system32\drivers\etc\" + $File
Endif
next

{edit}
The computer name parser and selection will have to be customized depending how you want to allocate your licenses.

[ 30. October 2002, 05:39: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#71265 - 2002-10-30 03:48 PM Re: Copying a file to a range of computers
dbeiser Offline
Fresh Scripter

Registered: 2001-03-22
Posts: 34
Loc: Melbourne, FL, USA
Where not running ADSI, this is an NT4 domain.

The above example does not address my statement, "Depending on which range of the name falls in I need to copy a particular hosts. file to the PC."

I need to read the workstation name and determine if it falls into a predetermined range of names, then assign the appropriate hosts. file for that range.

Example:

If $wksta is xxxxxe220 – xxxxxe250 copy hosts1. to $path\hosts.
If $wksta is xxxxxw100 – xxxxxw150 copy hosts2. to $path\hosts.
If $wksta is xxxxxm1 – xxxxxm60 copoy hosts3 to $path\hosts.

Note: All users have admin rights to the workstation during login.

Thanks,
_________________________
Dave Melbourne, FL

Top
#71266 - 2002-10-30 03:52 PM Re: Copying a file to a range of computers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The replace $ComputerName with @WKSTA and simplify Howards code.
_________________________
There are two types of vessels, submarines and targets.

Top
#71267 - 2002-10-30 03:53 PM Re: Copying a file to a range of computers
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
the script looks like it should work.

Have you tried it?
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#71268 - 2002-10-30 03:55 PM Re: Copying a file to a range of computers
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You're changing the rules on us. In the first post your ranges started at 1.

You only need ADSI to be installed on the one computer running the script. It does work in an NT4 domain.

The basic structure would remain the same. You need only add IF conditionals under each CASE to enumerate the range.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#71269 - 2002-10-30 03:57 PM Re: Copying a file to a range of computers
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I provided some sample code of an Admin script that could be executed from a central console relying on the computer name format in your first post. I can't be held responsible for incomplete and inaccurate info that you provided.

Is the information:
quote:
If $wksta is xxxxxe220 – xxxxxe250 copy hosts1. to $path\hosts.
If $wksta is xxxxxw100 – xxxxxw150 copy hosts2. to $path\hosts.
If $wksta is xxxxxm1 – xxxxxm60 copoy hosts3 to $path\hosts.

correct with regard to the way you wish the host file to be deployed?

{edit}obviously not{/edit}

[ 30. October 2002, 19:35: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#71270 - 2002-10-30 04:05 PM Re: Copying a file to a range of computers
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You also haven't stated whether you want this to run from a logon script or an admin script. I see you finally dribbled out a bit more info, mainly that "All users have admin rights".

Once agian, I ask... what part of the code are you having problems with? You said "I don't really have a clue where to start". Howard gave you a start with what little info you provided.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#71271 - 2002-10-30 05:39 PM Re: Copying a file to a range of computers
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
So far this thread is 13 posts long and I have to wonder how much you've benefitted. What you really need to do is provide as much info as possible and to outline in pseudo-code of flow chart fashion what you expect this to do.

With the limited information you're dribbling out, I doubt someone will write you an entire script you can run with. By outlining it and breaking it into individual tasks we can tackle one task at a time.

So... some more questions:

Admin or logon script? If admin, need some logging to ensure none get missed. If Logon, Admin rights exist but need to either check if updated or update regardless on every logon.

Any unique Hosts files? If all Hosts files within specified groups are identical with no exceptions then it's a non-issue, otherwise...

In the end, I still think Round Robin DNS 'A' records have merit. I did a bit of research and NT4 supports it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#71272 - 2002-10-30 06:06 PM Re: Copying a file to a range of computers
dbeiser Offline
Fresh Scripter

Registered: 2001-03-22
Posts: 34
Loc: Melbourne, FL, USA
I'm trying to post some test code I've come up with and I keep getting the following error during posting.

Sorry, we do not permit this HTML tag: Parenthesis in HTML tag

Any ideas?
_________________________
Dave Melbourne, FL

Top
#71273 - 2002-10-30 06:15 PM Re: Copying a file to a range of computers
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Use the code tags below the edit window and paste your code between the tags.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#71274 - 2002-10-30 06:22 PM Re: Copying a file to a range of computers
dbeiser Offline
Fresh Scripter

Registered: 2001-03-22
Posts: 34
Loc: Melbourne, FL, USA
I'm running this from a login script.

I will not be using ADSI nor will we be messing with DNS.

I have worked out some test samples, the first works the second doesn’t. Your input is appreciated.
code:
Working

$LOC = SUBSTR ("@WKSTA",6,4)

IF $LOC >= "M74" AND $LOC <= "M88"
? "IN RANGE"
ELSE
? "OUT OF RANGE"
ENDIF

As soon as I add other ranges to check it give me an error

$LOC = SUBSTR ("@WKSTA",6,4)
IF $LOC >= "M74" AND $LOC <= "M88"
IF $LOC >= "M130" AND $LOC <= "M144"
IF $LOC >= "M146" AND $LOC <= "M160"
? "IN RANGE"
ELSE
? "OUT OF RANGE"
ENDIF
ELSE
? "OUT OF RANGE"
ENDIF
ELSE
? "OUT OF RANGE"
ENDIF

Thanks,
_________________________
Dave Melbourne, FL

Top
#71275 - 2002-10-30 06:45 PM Re: Copying a file to a range of computers
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Nested IFs won't work.
You have to either use
code:
IF $LOC >= "M74" AND $LOC <= "M88"
ELSE
IF $LOC >= "M130" AND $LOC <= "M144"
ELSE
IF $LOC >= "M146" AND $LOC <= "M160"
ENDIF
ENDIF
ENDIF

or preferably
code:
SELECT
CASE $LOC >= "M74" AND $LOC <= "M88"
CASE $LOC >= "M130" AND $LOC <= "M144"
CASE $LOC >= "M146" AND $LOC <= "M160"
ENDSELECT

_________________________
There are two types of vessels, submarines and targets.

Top
#71276 - 2002-10-30 06:49 PM Re: Copying a file to a range of computers
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Here we go again... In your first post you clearly defined the ranges as contiguous (xxxxxM1 - xxxxxM400) then you changed it to xxxxxm1 – xxxxxm60 and now again something different. Are you going to change your story yet again?

If you don't have easy contiguous ranges that can be determined with IF and/or CASE statements then maybe you should setup an INI file to translate.

You are nesting IF conditions that don't make any sense. for example:
IF $LOC >= "M74" AND $LOC <= "M88"
  IF $LOC >= "M130" AND $LOC <= "M144"
the first IF <= "M88" contradicts the second >= M130".

You are also trying to do > and < comparison on strings which is fraught with problems. Better to leave the "M" out and convert the rest with VAL().
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#71277 - 2002-10-30 07:05 PM Re: Copying a file to a range of computers
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Les, I think we need to vote you a new title.

PostBuster [Big Grin]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#71278 - 2002-10-30 07:18 PM Re: Copying a file to a range of computers
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Is it just me? Dave said "This should be a snap" and it would be true if we had the information at hand.
Tell you what... I'll just sit on my hands and watch the show unless invited back in.

My apologies for my impatience.
_________________________
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 1 of 2 12>


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

Who's Online
0 registered and 369 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.146 seconds in which 0.099 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