日期:2014-05-16  浏览次数:21970 次

无法source hosts文件
前两天执行:source /etc/hosts 就没一点问题修改后的文件可以生效。今天再次修改hosts文件却无法执行 结果如下:  
[root@192 ~]# source /etc/hosts
-bash: 127.0.0.1: command not found
-bash: 192.168.5.199: command not found
-bash: 121.14.76.138: command not found
 

文件内容如下:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.5.199 iservice
121.14.76.138 esales.qq.com

如果重启系统貌似可以生效,但是现在要求不能重启服务器,source却报错不知何因,请各位帮忙看看 到底什么原因?

------解决方案--------------------
/etc/hosts只是简单的文本文件,不用重启也生效。
source执行的也是bash,只不过在父shell的环境中执行,hosts不是脚本使用source当然没用。
两天前执行成功,估计hosts是空的。
------解决方案--------------------
很明显是把“192.168.5.199”当命令来使用了。
------解决方案--------------------
很明显host文件不是shell解析的,怎么可以用source命令呢。