Windows 上的管線 |
|
c = "''some shell command''" -- e.g. 'dir' readfrom("|" .. c) -- this part will alway fail in standard Windows compiled binary print(read("*a"))
在 lua-l 中,David Burgess 寫道
On VC6, Lua 4.0.1 from the project menu Goto - "Project/Settings" Tab - "C/C++" Select "All configurations" Edit field - "Preprocessor definitions" and paste at the end of the existing string (which should already have something like "WIN32,_CONSOLE,_MBCS") POPEN,popen=_popen,pclose=_pclose
也嘗試了 Windows 的 lcc。
你可以在編譯器→設定面板的 #defines 中加入 POPEN。
不過,_popen 有個問題。Win32 API 說明文件中說明它只能在主控台應用程式中執行,所以如果你將 Lua 嵌入在 Windows 應用程式中,這會是個問題。不過,有一個補丁檔 [1] ,並且已在 SciTE 中測試過(這也提供了一個「quiet」版本的 os.execute)。