Lua os.execute with command line arguments

試著忘記壹切 提交于 2019-12-12 04:41:38

问题


I am running Lua on a Windows 7 machine and I am trying to launch a LabVIEW executable using Lua.

This is an example of the command line input that DOES work:

The text I use:

"C:\Program Files\National Instruments\LabVIEW 2009\LabVIEW.exe" "C:\Program Files\National Instruments\LabVIEW 2009\examples\viserver\cmdline.llb\CommandLine.vi" -- 4.0

However no matter how I try to format this in Lua, it complains:

'C:\Program' is not recognized as an internal or external command, operable program or batch file.

I currently have it formatted as the following with no success:

local s = [["C:\Program Files\National Instruments\LabVIEW 2009\LabVIEW.exe" "C:\Program Files\National Instruments\LabVIEW 2009\examples\viserver\cmdline.llb\CommandLine.vi" -- 4.0]]
os.execute(s)

I need help formatting that local string s to do the same as what I typed into the command prompt.


回答1:


Some quick reading online suggests that you might need to wrap your command string in an extra set of quotes. Like this I think:

[[""C:\Program Files\National Instruments\LabVIEW 2009\LabVIEW.exe" "C:\Program Files\National Instruments\LabVIEW 2009\examples\viserver\cmdline.llb\CommandLine.vi" -- 4.0"]]


来源:https://stackoverflow.com/questions/21263291/lua-os-execute-with-command-line-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!