免费注册 查看新帖 |

Chinaunix

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

这个MAC地址该如何取 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-04-30 23:41 |只看该作者 |倒序浏览
河南网通的客户端登录shell(针对linux的客户端)一部分内容 :
---
#to which interface link with Internet
  INTERNUM=`ifconfig -a | grep "HWaddr" | wc -l`
  if [ $INTERNUM -eq 0 ]; then
        echo "No net Interface can be found, may you type command such as insmod and ifup eth0 first"
        return 1
  fi
---
在solaris9 x86下执行这个shell时返回的是“No net Interface can be found, may you type command such as insmod and ifup eth0 first”

网卡是8139d的驱动都装过来,可以用。执行这个“ifconfig -a | grep "HWaddr" | wc -l”返回为“0”
获取MAC该怎么写这个shell。本人菜,帮帮忙。

论坛徽章:
0
2 [报告]
发表于 2007-05-01 00:35 |只看该作者
try:

INTERNUM=`ifconfig -a | grep "ether" | wc -l`

论坛徽章:
0
3 [报告]
发表于 2007-05-01 23:56 |只看该作者
原帖由 briangao 于 2007-5-1 00:35 发表
try:

INTERNUM=`ifconfig -a | grep "ether" | wc -l`

谢谢!
不过还是多帮帮看看,这个客户端依然不能继续,如下:
#if more than ONE eth installed, have to select one(只有一个“rtls0”)
  CMPNUM=0
  if [ "$INTERNUM" -gt "$CMPNUM" ]; then
        ifconfig -a | grep "ether" | awk '
          BEGIN {
                i=0;
                printf("All names of your net interface installed\n");
                printf("-----------------------------------------\n");
          }
          {
                printf("\t%s\t%d\n", $1, i);
                i++;
          }'
         echo -n "Input one name to hace access with Internet (eth0): "       
         read INTERNAME
         if [ ! $INTERNAME ]; then   #default name is eth0
                INTERNAME="eth0"
         fi
         #if the name input is correct or not
         TMP_NUM=`ifconfig -a | grep "ether" | grep "$INTERNAME" | wc -l`
         if [ $TMP_NUM -eq 0 ]; then
                echo "You have input an invalid name of net interface"
                return 1
         fi
  else
        INTERNAME=`ifconfig -a |grep "ether" |        awk '{print $1}'`
  fi
  echo "The name of interface is: " $INTERNAME
----
无论输入什么均有错误提示:
把“eth0"都改为"rtls0"一样
这个是在linxu下客户端,用过可以上网,但在solaris下不知该怎么办,劳驾,帮帮,

论坛徽章:
0
4 [报告]
发表于 2007-05-02 00:02 |只看该作者
Can you post your ifconfig -a result?

论坛徽章:
0
5 [报告]
发表于 2007-05-02 19:50 |只看该作者
#ifconfig -a




[ 本帖最后由 yuuxt 于 2007-5-2 19:54 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2007-05-02 20:48 |只看该作者
原帖由 yuuxt 于 2007-5-2 19:50 发表
#ifconfig -a





  哥们,你这个是怎么切下来的

论坛徽章:
0
7 [报告]
发表于 2007-05-03 03:02 |只看该作者
It seems that all you want to achieve is to get an active NIC for internet access. If that is the case, try the following one liner:
  1. INTERFACE=`ifconfig -a|grep -v lo0|grep UP|head -1|awk -F: '{print $1}'`;[ -z "$INTERFACE" ] || echo $INTERFACE
复制代码

Your initial script was adopted from Linux, which is not the best way of implementing it.

论坛徽章:
0
8 [报告]
发表于 2007-05-04 13:23 |只看该作者
由于只有linux下的客户端,所以只能改这用
附上客户端一部分:

[ 本帖最后由 yuuxt 于 2007-5-4 13:24 编辑 ]

ecou.rar

1.57 KB, 下载次数: 13

客户端

论坛徽章:
0
9 [报告]
发表于 2007-05-05 16:00 |只看该作者
俺也是河南的网通宽带,也是急盼啊

论坛徽章:
0
10 [报告]
发表于 2007-05-05 19:44 |只看该作者
OK. Then try to replace
  1. ifconfig -a |grep  "HWaddr"
复制代码
with
  1. ifconfig -a|grep -v lo0|grep UP|awk -F: '{print $1}'
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP