info = os.popen("nbtstat -A 172.24.70.12").read()
print info
process = subprocess.Popen(["nbtstat", "-A", ip], stdout=subprocess.PIPE)
process.wait()
result = process.stdout.read()
print(result)
p = subprocess.Popen(['arp', '-a'], stdout=subprocess.PIPE)
print p.stdout.read()
我是想抓同一個 subnet 裡其他電腦的 mac address
> --
> 您已訂閱「Google 網上論壇」的「python.tw」群組,因此我們特別傳送這封郵件通知您。
> 如要在網路上查看這項討論,請造訪 https://groups.google.com/d/msg/pythontw/-/z5_Qz_rPh-8J。
>
> 如要在此群組張貼留言,請傳送電子郵件至 pyth...@googlegroups.com。
> 如要取消訂閱此群組,請傳送電子郵件至 pythontw+u...@googlegroups.com。
> 如需更多選項,請造訪此群組:http://groups.google.com/group/pythontw?hl=zh-TW。
Traceback (most recent call last):
File "E:\workspace\test\src\ipmac2.py", line 4, in <module>
p = subprocess.Popen(args, stdout=subprocess.PIPE)
File "C:\Python27\Lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python27\Lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 2] 系統找不到指定的檔案。
#-*- coding: utf-8 -*-
import subprocess
args = ['nbtstat', '-A', '172.24.70.12']
p = subprocess.Popen(args, stdout=subprocess.PIPE)
p.wait()
result = p.stdout.read()
print result
#-*- coding: utf-8 -*-
import subprocess
args = ['nbtstat', '-A', '172.24.70.12']
p = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE)
p.wait()
result = p.stdout.read()
print result
#-*- coding: utf-8 -*-
import subprocess
args = ['c:/Windows/System32/nbtstat.exe', '-A', ip]
p = subprocess.Popen( args, shell=True,stdout=subprocess.PIPE)
p.wait()
result = p.stdout.read()
print result
print os.path.exists(r'C:\Windows\System32\nbtstat.exe')
On Thursday, September 6, 2012 2:02:35 PM UTC+8, evenrain wrote:我剛想到一件事,因為某些緣故,我是用 32-bite 的 Python 在 64-bite 的 Win7 上跑用檔案總管去找,nbtstat 是位於 C:\Windows\System32\nbtstat.exe然後我寫了一小段 codeprint os.path.exists(r'C:\Windows\System32\nbtstat.exe')結果得到的是 False
這裡出現False是因為你用了r'' 吧,r''表明它是一個RegExp。
如要在網路上查看這項討論,請造訪 https://groups.google.com/d/msg/pythontw/-/Qi7tEddf82MJ。
2012/9/6 evenrain <even...@gmail.com>:
你要不要考慮自己用 raw socket 寫 arp 還是乾脆 call ping 再 call arp 算了 XD (嘴泡
2012/9/7 Keith Yang <keit...@gmail.com>:
x64 windows 的 x32 版 nbtstat.exe 會被 winsxs 放在另外的地方
在我的系統上是 C:\Windows\winsxs\amd64_microsoft-windows-nbtstat_31bf3856ad364e35_6.1.7600.16385_none_fa057619380ff901\nbtstat.exe你要不要考慮自己用 raw socket 寫 arp 還是乾脆 call ping 再 call arp 算了 XD (嘴泡
--
您已訂閱「Google 網上論壇」的「python.tw」群組,因此我們特別傳送這封郵件通知您。
如要在網路上查看這項討論,請造訪 https://groups.google.com/d/msg/pythontw/-/4navnCEdJ6cJ。