免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3096 | 回复: 8
打印 上一主题 下一主题

重置网络 /etc/init.d/network 脚本问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-29 10:45 |只看该作者 |倒序浏览
今天试了一下这两个命令:
ifconfig pcn0 unplumb
ifconfig pcn0 plumb

用 ifconfig -a 查看pcn0 状态 发现inet和netmask都变成0了
于是用/etc/init.d/network脚本重设网络, 但结果有点让人摸不着头脑

# /etc/init.d/network
Setting netmask of pcn0 to 255.255.255.0
configuring IPv4 interfaces: pcn0
./network: shcat :not found
Hostname: unknown

结果最后一行, hostname: unknown 。但是我的网络配置文件绝对是ok的。
然后看到 ./network: shcat :not found
可能network脚本有点问题

grep shcat /etc/init.d/network
发现多处出现 shcat

set -- 'shcat /etc/hostname.$1'
for i in 'shcat /etc/dhcp\.$1'; do
.....
遂备份network原文件,编辑network, 用cat代替全部shcat 后保存退出
cp /etc/init.d/network /etc/init.d/network.orig
vi /etc/init.d/network
g:/shcat/s//cat/
ZZ

重新执行network脚本
/etc/init.d/network
Setting netmask of pcn0 to 255.255.255.0
configuring IPv4 interfaces: pcn0
Hostname: sol9

这下就好了……无语了。

我的问题是: 这个shcat 到底是什么? 起先以为是 sh cat, 结果执行脚本仍然出错。全部改成cat就没问题了。:em12:

论坛徽章:
0
2 [报告]
发表于 2007-03-29 11:01 |只看该作者
直接用ifconfig就行了,还用什么network脚本,我从来不用那个脚本。

论坛徽章:
0
3 [报告]
发表于 2007-03-29 11:04 |只看该作者
原帖由 zyl555 于 2007-3-29 11:01 发表
直接用ifconfig就行了,还用什么network脚本,我从来不用那个脚本。


我一般也用ifconfig
但是重新激活网卡要输入最少两条命令吧
还要手动设置hostname

脚本自有脚本的方便之处,我只是想知道为什么这里用shcat

感谢xd的回答

论坛徽章:
0
4 [报告]
发表于 2007-03-29 11:12 |只看该作者
This is because Solaris 10 doesn't use /etc/init.d/network to start network anymore. It use /lib/svc/method/net-physical script. net-physical script sources /lib/svc/share/net_include.sh file before executing network commands. shcat is defined in net_include.sh  as:

  1. shcat() {
  2.         while [ $# -ge 1 ]; do
  3.                 while read i; do
  4.                         echo "$i"
  5.                 done < $1
  6.                 shift
  7.         done
  8. }
复制代码

论坛徽章:
0
5 [报告]
发表于 2007-03-29 11:40 |只看该作者
原帖由 briangao 于 2007-3-29 11:12 发表
This is because Solaris 10 doesn't use /etc/init.d/network to start network anymore. It use /lib/svc/method/net-physical script. net-physical script sources /lib/svc/share/net_include.sh file befor ...


brian 换头像了? 感觉以前那个更有科技感.

我用的不是10, 是9

能解释 shcat 为什么会出现 not found 的结果吗? 9里面没有shcat的定义?

论坛徽章:
0
6 [报告]
发表于 2007-03-29 11:57 |只看该作者
brian 换头像了? 感觉以前那个更有科技感.
Oops, what was a mistake. Change it back
我用的不是10, 是9
If Solaris 9, it should be in /etc/rcS

论坛徽章:
0
7 [报告]
发表于 2007-03-29 12:58 |只看该作者
原帖由 briangao 于 2007-3-29 11:57 发表
Oops, what was a mistake. Change it back
If Solaris 9, it should be in /etc/rcS


如你所说,shcat的定义在rcS 。
这样看来,并不是所有/etc/init.d 目录下的脚本都可以手动执行了. 当然带 start|stop 参数的脚本肯定可以

谢brian

论坛徽章:
0
8 [报告]
发表于 2007-03-29 13:07 |只看该作者
。speed

论坛徽章:
0
9 [报告]
发表于 2007-03-29 21:47 |只看该作者
shcat is a shell function defined in /etc/rcS. It's intended to do
what 'cat' does when the cat executable may not be available (if /usr
isn't mounted).

http://www.sunmanagers.org/archives/1997/0056.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP