如何在Ruby中执行Windows CLI命令? [英] How to execute Windows CLI commands in Ruby?
问题描述
我有一个文件位于目录C:\Documents和Settings\test.exe,但当我写命令`C:\Documents和Settings\test.exe
在单个qoutes(我不能在这个框中显示),用于执行Ruby中的命令,我不能这样做,我收到的错误是没有文件或目录找到。我已经尝试用//和\替换\,但没有什么似乎工作。我也使用了system,IO.popen和exec命令,但所有的努力都是徒劳的。还有exec命令使程序退出,我不想发生。
提前感谢。
`C:\Documents和Settings\test.exe`
/ pre>
或
`exec'C:\Documents和Settings\test.exe`
或qoutes中的任何内容
I have a file located in the directory "C:\Documents and Settings\test.exe" but when I write the command
`C:\Documents and Settings\test.exe
in single qoutes(which I am not able to display in this box), used for executing the commands in Ruby, I am not able to do so and the error that I recieve is No file or Directory found. I have tried replacing "\" with "//" and "\" but nothing seems to work. I have also used system, IO.popen and exec commands but all efforts are in vain. Also exec commands makes the program to make an exit which I don't want to happen.Thanks in advance.
解决方案`"C:\Documents and Settings\test.exe"`
or
`exec "C:\Documents and Settings\test.exe"`
or whatever in qoutes
这篇关于如何在Ruby中执行Windows CLI命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!