巧用hosts,使得脚本可以如鱼得水似的切换环境
1、C:\Windows\System32\drivers\etc在这个目录下有个hosts文件,
文件内容如下:使用线上和线下不同的地址来指向同一个域名,便可以共用同一套脚本,而执行在不同的环境中。
# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 114.55.188.77 pro.labbigdata.com # 192.168.1.38 pro.labbigdata.com