ChinaUnix.net
相关文章推荐:

SHELL 获取 IP地址

我在网上查到用如下语句可以获取主机ip地址 grep `hostname` /etc/hosts| awk '{print $1}' 但我把这条语句写到脚本里,就报错 脚本: root@:/script>more ll.sh ipip=`grep `hostname` /etc/hosts| awk '{print $1}'` echo ${ipip} 报错: usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] -e pattern_list... [-f pattern_file...] [file...] usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] [-e pattern_list...] -f pa...

by erin_lyj - Shell - 2007-08-12 16:38:28 阅读(9968) 回复(10)

相关讨论

该语句可以获取客户端ip地址,但有时返回多个ip地址,或返回空值,可能写成多行语句就没问题,但因编程序的需要,又必须写成一行。有哪位高手解答一二? who -x|grep `who -m|awk '{print $2}` |awk '{print $6}'

by beyonder - 其他UNIX - 2004-07-14 18:16:40 阅读(889) 回复(4)

请教 在unix shell中如何获取本机ip地址 【注 我的/etc/host中主机ip地址对应的名称不是固定的或者说是不知到的,并不是通常的localhost】

by wws75111 - 其他UNIX - 2003-10-27 17:11:49 阅读(2452) 回复(4)

请教 在unix shell中如何获取本机ip地址 【注 我的/etc/host中主机ip地址对应的名称不是固定的或者说是不知到的,并不是通常的localhost】

by wws75111 - Shell - 2003-10-27 10:29:26 阅读(6774) 回复(15)

#!/bin/sh FILE=/home/ip_apnic rm -f $FILE rm -f CNC rm -f OTHER rm -f CHINANET rm -f CRTC wget http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest -O $FILE grep 'apnic|CN|ipv4|' $FILE | cut -f 4,5 -d'|'|sed -e 's/|/ /g' | while read ip cnt do mask=$(cat << EOF | bc | tail -1 pow=32; define log2(x) { if (x<=1) return (pow); pow--; return(log2(x/2)); } log2($cnt) EOF) echo $ip/...

by jiedushi - Shell - 2011-03-28 20:30:36 阅读(3272) 回复(9)

怎么用shell 修改ip呢 ---------- 思路有呢: 用 echo -------------------- 问题来了:1。怎么自选网卡 2。就是键盘键入信息怎么写进网卡 那位高手 指点一下!

by 87250222 - Shell - 2006-10-02 16:42:32 阅读(2584) 回复(15)

solaris 10 finger -f dpcds ??? pts/14 5:14 Thu 09:16 10.101.2.35 CustomsAdmin ??? pts/2 52 Tue 13:26 10.101.2.91 CustomsAdmin ??? pts/11 Thu 14:26 10.101.2.91 CustomsAdmin ??? pts/12 2:07 Thu 12:02 10.101.2.91 CustomsAdmin ??? pts/15 ...

by aigo_H - Shell - 2008-01-10 14:42:57 阅读(1271) 回复(2)

局域网中有数台机器,通过主机名可以ping通 如何编写一个shell脚本,通过主机名得到其ip

by xueruini - Shell - 2003-04-24 08:53:56 阅读(1221) 回复(5)

shell 如何处理把 起始ip:4.12.0.0 结束ip:4.19.77.255 之间的ip地址列出来,谢谢!

by yzjboy - Shell - 2006-03-07 22:28:27 阅读(1499) 回复(7)

getsockname(sockfd,&localaddr,&locallen); 我取得的本机ip怎么是0.0.0.0啊? 我bind的是INADDR_ANY, 在不知道本机ip的情况下怎么才能获得本机的ip啊?

by mu_mu8309 - C/C++ - 2007-11-30 09:50:15 阅读(2782) 回复(3)

到来一个TCP连接,用getsockname()获取该网卡本地地址,BIND 时 用 INADDR_ANY; 得到的网卡地址是0,抓的是accept得到的sd。 是不是 INADDR_ANY 只能得到0?

by wswn5456 - C/C++ - 2007-11-29 09:42:36 阅读(2081) 回复(4)