File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77
88import os
9+ import commands
910
1011
1112def test_memory_usage ():
@@ -42,7 +43,8 @@ def test_get_local_ip():
4243 """
4344 获取本地ip地址
4445 """
45- cmd = "LC_ALL=C ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'"
46+ # cmd = "LC_ALL=C ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'"
47+ cmd = "ifconfig"
4648 print cmd
4749 # result = os.system(cmd)
4850 result = os .popen (cmd ).read ()
@@ -53,9 +55,19 @@ def test_get_local_ip():
5355 return ip_list
5456
5557
58+ def test_commands ():
59+ """
60+ 获取状态和回显
61+ :return:
62+ """
63+ status , output = commands .getstatusoutput ('ifconfig' )
64+ print status , output
65+
66+
5667if __name__ == '__main__' :
5768 # test_memory_usage()
58- test_get_local_ip ()
69+ # test_get_local_ip()
70+ test_commands ()
5971
6072"""
6173测试结果:
You can’t perform that action at this time.
0 commit comments