Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新IP地址的获取方式 #17

Merged
merged 1 commit into from
Mar 24, 2020
Merged

更新IP地址的获取方式 #17

merged 1 commit into from
Mar 24, 2020

Conversation

higkoo
Copy link
Contributor

@higkoo higkoo commented Mar 23, 2020

ifconfig 和 route 命令,写绝对路径会导致兼容性不好。

  1. Debian系统路径对应: /sbin/ifconfig 和 /sbin/route
  2. 原命令获取的IP地址兼容性不好,会带“addr:”在前面。 addr:192.163.10.31
  3. 本地配置正确的情况下 hostname -i是能拿到正确IP的

ifconfig 和 route 命令,写绝对路径会导致兼容性不好。
1. Debian系统路径对应: /sbin/ifconfig 和 /sbin/route
2. 原命令获取的IP地址兼容性不好,会带“addr:”在前面。 addr:192.163.10.31
3. 本地配置正确的情况下 `hostname -i`是能拿到正确IP的
@UlricQin
Copy link
Member

  • hostname -i 是对系统配置苛求太高
  • 可以把现在的shell,去掉绝对路径/usr/sbin,直接使用route和ifconfig命令

@UlricQin
Copy link
Member

UlricQin commented Mar 23, 2020

所有的shell的改动提到一个pr里就行,毕竟是同一个问题的改动 :)
要不把绝对路径拿掉你再提一个pr?

@UlricQin
Copy link
Member

UlricQin commented Mar 23, 2020

addr:192.163.10.31 这个的解决方法可以再加一个管道
| awk -F ':' '{print $NF}'

@UlricQin
Copy link
Member

我来搞吧

@UlricQin UlricQin merged commit 7325c7d into ccfos:master Mar 24, 2020
@higkoo higkoo deleted the patch-1 branch March 29, 2020 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants