Hello,
I’m getting failures when I try to run these two Ruby scripts inside
this one here. But, in the command shell, when I go to that directory, I
can run those other two Ruby scripts just fine. All I’m doing here is
parsing out particular filetypes, by virtue of the filenames and
extensions, and then trying to run separate Ruby scripts on those files.
require ‘yaml’
require ‘fileutils’
Dir.chdir(“F:/workflows/grafix/images-BNA”)
config =
YAML.load_file(“F:/workflows/grafix/images-BNA/SMMS-images.yaml”)
data1 = config[“filenames”]
data2 = config[“destinations”]
data1.keys.each do |filetype|
filenames = data1[filetype]
target = data2[filetype]
filenames.split(", ").each do |pattern|
if pattern == “aicpa*.gif”
puts pattern
begin
puts “executing the AICPA GIF script.” E:/Apps/scripts/ruby/FileTrain/SMMS2/AICPA/AICPA_gif.rb
rescue
puts “That Ruby script, AICPA_gif.rb, did not run.”
end
end
if pattern == “aicpa*.jpg”
puts pattern
begin
puts “executing the AICPA JPEG script.” E:/Apps/scripts/ruby/FileTrain/SMMS2/AICPA/AICPA_jpeg.rb
rescue
puts “That Ruby script, AICPA_jpeg.rb, did not run.”
end
end
end
end
This is my output:
aicpa*.gif
executing the AICPA GIF script.
That Ruby script, AICPA_gif.rb, did not run.
aicpa*.jpg
executing the AICPA JPEG script.
That Ruby script, AICPA_jpeg.rb, did not run.
Yes, I use backticks. I use them a lot because I have to do a lot of
command shell stuff.
I tried using system("…") here, but, that didn’t work. I got it to
work here, at least where it could tell me that the scripts did not run.
I’m sorry, but, I don’t know what you mean by “load” or “require.” Do I
have to “require” an outside script that I want to run inside this
script? I’ll look up what “load” mean.
Thanks.
load and require are for dealing with Ruby code. In your code example
your files end with .rb, so I assume they contain ruby code. That’s why
I recommend you explore load and require.