none
VB Script to telnet and write data to Hostfile? RRS feed

  • Question

  • Hello, Is it possible to telnet one specific server, if the connection is successful then write entries to host file ? 

    I have multiple file servers, I need to modify the client host file as per the connectivity. So, I need to telnet the server first, if connection works, then write the DNS entries to hostfile, if telnet does not makes a successfull session, then move to next server, check connectivity, if it works then write to host file else move to next server. 

    Possible ? 

    Sunday, December 21, 2014 9:12 PM

Answers

  • Requirement : I have multiple domains and multiple SCCM servers. Sometime SCCM servers talk to wrong server and discover wrong site code. 

    I want to create a script that will run, telnet all SCCM one by one, and one telnet works, correct DNS entries are entered in host file. 

    As far as host file is concerned, its outdated but we can't change whole infra. 

    Right now we manually telnet and add entries. 

    Hope this clears up things. 

    This is absolutely the case where you do not want to do this.  You MUST fix your DNS servers and your routers or modifying the hosts file willjust make things worse.

    You need to talk to you network engineers to understand how to fix this.  it is likely that lack of name resolution for SCCM is due to firewall, router or system configuration issues.  Kludging a patch will only aggravate the issue.  Please take steps to fix the cause of your problem.


    ¯\_(ツ)_/¯

    Monday, December 22, 2014 11:22 AM

All replies

  • In the 21st century we do no tuse the hosts file.  If we need clarification of hosts we use DNS.

    You will alos find thaat Telnet is not normally availabe in Windows.


    ¯\_(ツ)_/¯

    Sunday, December 21, 2014 11:05 PM
  • In the 21st century we do no tuse the hosts file.  If we need clarification of hosts we use DNS.

    You will alos find thaat Telnet is not normally availabe in Windows.


    ¯\_(ツ)_/¯

    Its not about DNS or hosts or the telnet host. Its about the script. 

    Is vb script smart enough to do that ? any suggestions...

    Sunday, December 21, 2014 11:24 PM
  • In the 21st century we do no tuse the hosts file.  If we need clarification of hosts we use DNS.

    You will alos find thaat Telnet is not normally availabe in Windows.


    ¯\_(ツ)_/¯

    Its not about DNS or hosts or the telnet host. Its about the script. 

    Is vb script smart enough to do that ? any suggestions...


    Sorry but VBScript is not very smart at all.  Iti si no smarter than the most amateur scripter.  VBScript will never get a college degree.

    ¯\_(ツ)_/¯

    Monday, December 22, 2014 12:29 AM
  • In the 21st century we do no tuse the hosts file.  If we need clarification of hosts we use DNS.

    You will alos find thaat Telnet is not normally availabe in Windows.


    ¯\_(ツ)_/¯

    Its not about DNS or hosts or the telnet host. Its about the script. 

    Is vb script smart enough to do that ? any suggestions...


    Sorry but VBScript is not very smart at all.  Iti si no smarter than the most amateur scripter.  VBScript will never get a college degree.

    ¯\_(ツ)_/¯

    What else can be used here ? Any suggestions ?

    Just to reduce the work of checking connectivity, and then adding entried to hostfile. 

    Monday, December 22, 2014 12:34 AM
  • jrv is trying to tell you that you should not be trying to modify the hosts file. Why do you need to do this? Modifying the hosts file is common malware behavior.


    -- Bill Stewart [Bill_Stewart]

    Monday, December 22, 2014 2:35 AM
    Moderator
  • jrv is trying to tell you that you should not be trying to modify the hosts file. Why do you need to do this? Modifying the hosts file is common malware behavior.


    -- Bill Stewart [Bill_Stewart]

    Yes, I understand that DNS should be used. But right now. I'm looking for a script that first checks the connectivity via telnet, if connection is through then it should write to host file. 

    Kepping host file aside, since you're moving to a different topic (DNS), can you just let me know if vb script or PS can check connection via telnet and then perform an action ? 

    Monday, December 22, 2014 4:25 AM
  • jrv is trying to tell you that you should not be trying to modify the hosts file. Why do you need to do this? Modifying the hosts file is common malware behavior.


    -- Bill Stewart [Bill_Stewart]

    Yes, I understand that DNS should be used. But right now. I'm looking for a script that first checks the connectivity via telnet, if connection is through then it should write to host file. 

    Kepping host file aside, since you're moving to a different topic (DNS), can you just let me know if vb script or PS can check connection via telnet and then perform an action ? 

    Why do you insist on telnet?  What caonnectivity are you trying to check.  Connectivity is a routing and name resolution issue.  What needs to be asked is why can't a host reolve a name.  Perhaps you have router issues.  Perhaps you have a bad DNS server.  You need to as the corect set of technical questions.  The hosts file is no longer used.  It is an old Unix hold over form pre-DNS days.  It is maintained for simmple stand-alone non-Internet connected hosts.  In those cases the local hosts in WInodws are resoved by NetBIOS.  Ifyou have non-NetBIOS machines like a Unix system then you might need to distribute a hosts file.  Inthat case you would jsut copy the hosts file to all Unix and IWndpws systems.  In todays world you would likely install DNS on a server and use that.  If you have no Windows servers then install DNS on the u=Unix box (it comes with all Unix systems). If you have no Unix systems then you can install one of the many free DNS servers for Windows.

    As far as editing hosts over Telnet via a script...I think you are SOL.  It can be done but you need to get a consultant to build it for you.


    ¯\_(ツ)_/¯

    Monday, December 22, 2014 10:53 AM
  • Actually a simple solution would be to copy locally then use PowerShell to edit then copy back to the target using the Admin share "C$".

    But then you already thought of that.  You are not an Admin and you are trying to drive your co-worker nuts by redirecting his connection to google.  I do this periodically for fun but then I know how to do this and my buddy does it to me for fun. 

    It is a bad habit that many of us geeks have but then we have done our homework.  You have not.  We will not tell you the answer.  Where would the fun be if all magicians divulged their secrets?  Do your homework.  One day you will understand what us Wizards know ......!!!

    Until the future ....


    ¯\_(ツ)_/¯

    Monday, December 22, 2014 11:01 AM
  • Requirement : I have multiple domains and multiple SCCM servers. Sometime SCCM servers talk to wrong server and discover wrong site code. 

    I want to create a script that will run, telnet all SCCM one by one, and one telnet works, correct DNS entries are entered in host file. 

    As far as host file is concerned, its outdated but we can't change whole infra. 

    Right now we manually telnet and add entries. 

    Hope this clears up things. 

    Monday, December 22, 2014 11:08 AM
  • Requirement : I have multiple domains and multiple SCCM servers. Sometime SCCM servers talk to wrong server and discover wrong site code. 

    I want to create a script that will run, telnet all SCCM one by one, and one telnet works, correct DNS entries are entered in host file. 

    As far as host file is concerned, its outdated but we can't change whole infra. 

    Right now we manually telnet and add entries. 

    Hope this clears up things. 

    This is absolutely the case where you do not want to do this.  You MUST fix your DNS servers and your routers or modifying the hosts file willjust make things worse.

    You need to talk to you network engineers to understand how to fix this.  it is likely that lack of name resolution for SCCM is due to firewall, router or system configuration issues.  Kludging a patch will only aggravate the issue.  Please take steps to fix the cause of your problem.


    ¯\_(ツ)_/¯

    Monday, December 22, 2014 11:22 AM
  • This is what I'm trying to say, the infra is very complex and this can't be fixed. 

    This the scenario possible ? telnet..and adding entries.. 

    Monday, December 22, 2014 11:25 AM
  • This is what I'm trying to say, the infra is very complex and this can't be fixed. 

    This the scenario possible ? telnet..and adding entries.. 

    Back to square one.  You cannot script Telnet.  Telnet  does not run on WIndows by default.  Most servers and corporrate security standards do not allow tenet server to be run.

    Now what is you question about scripting?


    ¯\_(ツ)_/¯

    Monday, December 22, 2014 11:45 AM
  • Hello, Is it possible to telnet one specific server, if the connection is successful then write entries to host file ?


    As others have told you, the native version of telnet is not scriptable. If you must edit a remote server's host file, why not use a share connection or else psexec.exe?
    Monday, December 22, 2014 2:57 PM
  • If the network infrastructure is not set up properly, then band-aiding solutions with telnet and manually editing hosts files is not going to improve the situation (and will actually make things worse and increase confusion). As already noted, you will need to fix the underlying infrastructure problems before you will be able to use an enterprise solution such as SCCM. SCCM, and other enterprise solutions like it, assume that the infrastructure is set up properly. If that is not the case, then you can't assume these solutions are going to work properly.

    -- Bill Stewart [Bill_Stewart]

    Monday, December 22, 2014 3:25 PM
    Moderator