Created
September 18, 2014 02:01
-
-
Save hymkor/fadd5ce20b4c09008029 to your computer and use it in GitHub Desktop.
ゲストOSからホストOSのIPアドレスを確実に得るにはどうすればいいんだ。みんなの知恵をわけてくれ ref: http://qiita.com/zetamatta/items/73b294ba923f479b9907
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::rem:: --[[ vim:set ft=lua: | |
@lua "%~f0" %1 %2 %3 %4 %5 %6 %7 %8 %9 & exit /b | |
]]-- | |
function getGateway() | |
local ipconfig = io.popen("ipconfig","r") | |
for line in ipconfig:lines() do | |
local m = line:match("デフォルト.*%s([0-9]+%.[0-9]+%.[0-9]+%.[0-9]+)") | |
if m then | |
ipconfig:close() | |
return m | |
end | |
end | |
ipconfig:close() | |
end | |
print(getGateway()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✏ hostip | |
10.0.2.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment