Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby IO.popen权限被拒绝_Ruby_Batch File_Ceedling - Fatal编程技术网

Ruby IO.popen权限被拒绝

Ruby IO.popen权限被拒绝,ruby,batch-file,ceedling,Ruby,Batch File,Ceedling,我很快就能让微芯片MPLABX MDB(调试器)与名为ceedling的自动化测试套件一起工作。我有一个名为sim\u test\u fixture.rb的ruby文件 此文件用于打开mdb.bat并向其传递一个名为sim_instructions.txt的配置文件。当我运行ruby文件时,会出现一个权限拒绝错误。为什么呢 该脚本运行命令mdb.bat C:\Users\MichaelMi\Documents\SourceTree\LED Lighting Driver\test\simulat

我很快就能让微芯片MPLABX MDB(调试器)与名为ceedling的自动化测试套件一起工作。我有一个名为
sim\u test\u fixture.rb的ruby文件

此文件用于打开
mdb.bat
并向其传递一个名为
sim_instructions.txt
的配置文件。当我运行ruby文件时,会出现一个权限拒绝错误。为什么呢

该脚本运行命令mdb.bat C:\Users\MichaelMi\Documents\SourceTree\LED Lighting Driver\test\simulation\sim\u instructions.txt
当我自己运行命令时,它工作得很好。只有当我尝试从下面的ruby文件运行它时,它才会失败

require 'rbconfig'
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)

OUT_FILE = "./test/simulation/out.txt"
File.delete OUT_FILE if File.exists? OUT_FILE
path = '"C:\Program Files (x86)\Microchip\MPLABX\v5.05\mplab_platform\bin\"mdb.bat C:\Users\MichaelMi\Documents\SourceTree\LED-Lighting-Driver\test\simulation\sim_instructions.txt'
var = IO.popen(path)
Process.wait
if File.exists? OUT_FILE
    file_contents = File.read OUT_FILE
    file_contents.gsub!("\n", "")
    print file_contents
end 

我不是100%确定的差异,但这段代码的工作

require 'rbconfig'
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
OUT_FILE = "./test/simulation/out.txt"
File.delete OUT_FILE if File.exists? OUT_FILE
if is_windows
    path = '"C:\\Program Files (x86)\\Microchip\\MPLABX\\v5.05"'
    var = IO.popen(path + "\\mplab_platform\\bin\\mdb.bat ./test/simulation/sim_instructions.txt > " + OUT_FILE)
else
    var = IO.popen("#{ENV['MPLABX_ROOT']}mplab_ide/bin/mdb.sh ./test/simulation/sim_instructions.txt > " + OUT_FILE)
end
Process.wait
if File.exists? OUT_FILE
    file_contents = File.read OUT_FILE
    print file_contents
end

这个问题不是很相关,是吗?它无法打开批处理文件。请将关闭的
放在批处理文件路径的
mdb.bat
后面,然后将其参数路径也放在
之间。。。