[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

script that will copy a hosts file

Posted on 2006-04-12
8
Medium Priority
?
790 Views
Last Modified: 2008-01-09
I need a script that will copy a hosts file I maintain on my Linux (SAMBA PDC) server to my XP clients. Instead of reinventing I'm just looking to see if anyone has already done this and if so could send me the .bat file.

mkelly@infinitybluewater.com
0
Comment
Question by:infinityit
8 Comments
 
LVL 22

Assisted Solution

by:pjedmond
pjedmond earned 375 total points
ID: 16438871
Just add the following line to the logon.bat file:

copy N:\hosts C:\windows\hosts

There are a couple of problems here in that the user copying the file must have administrative rights to do this, and also windows XP home, and professional seem to use the aforementioned direcory, and C:\WINNT...so if someone would like to expand on the concept.

You need to have created the samba share:
-------------------------------
[ netlogon]
  comment = Network Logon Share
  path = /home/netlogon
  guest ok = yes
  writable = no
  share modes = no
  browseable = no
--------------------------------

Note that this is the samba 3.x version.

HTH:)
0
 

Author Comment

by:infinityit
ID: 16439015
HTH,
The command
copy N:\hosts C:\windows\hosts

looks to me like it's copying from a windows mapped drive (N:) to the windows system drive.

My hosts file will be in /home/netlogon on the Samba server and from there I want the script to copy the file to the Windows system drive (which is actually c:\windows\system32\drivers\etc)

My [netlogon] in smb.conf is exactly as you've written.
Thanks,
Mark
0
 
LVL 3

Expert Comment

by:ryanhunt
ID: 16443363
Why don't you just setup a DNS (bind, djbdns) server on the Linux box, and add the linux box as a secondary (or tertiary) to the windows machines? It'll be much easier in the long run. It'll also get you around the problems of the users needing to be Administrator etc etc.

I guess you want the login script to look like this:

net use N: \\sambaserver\netlogon
copy N:\hosts c:\windows\system32\drivers\etc

also you'd want to add a cron job on the linux box that copys the /etc/hosts file to one in the /home/netlogon folder (using the example above)

Ryan.
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 

Author Comment

by:infinityit
ID: 16445582
The DNS idea sounds like a good one. Do you know of a resource I can refer to that will guide me through that process?
Thanks,
Mark
0
 
LVL 2

Accepted Solution

by:
guruyaya earned 375 total points
ID: 16451757
I have to disagree that DNS is a good way to solve this problem. First, it`s a service that was crackers favorite for some time in the past. It`s better nowdays, yet it is a service meant for bigger, more complex networks. Yet host file coppying should be quite a mess. I`ve solved the problem, using samba. Just by adding thease lines

wins support = yes
name resolve order = wins hosts lmhosts bcast

Will  enable you to read the contant of the hosts file on every XP computer on the net.
0
 
LVL 2

Expert Comment

by:guruyaya
ID: 16451761
Oh, one more thing

If you wish to enbale a DNS after all, a good guide is
http://tldp.org/HOWTO/DNS-HOWTO.html

Have a nice day
0
 

Author Comment

by:infinityit
ID: 16453141
OK I already have "wins support = yes" in my conf file. If I follow it with "name resolve order = wins hosts lmhosts bcast" does that mean every XP box on my network will use the hosts file on the Samba box after it tries wins to resolve providing the XP boxes use wins?
0
 
LVL 2

Expert Comment

by:guruyaya
ID: 16457217
I belive so. And I`m quite sure that trying it won`t blow any computer :)
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question