Hi,
Can someone please tell me how you can can call out another Ruby script?
I have a lot of image processing scripts. Sometimes, rarely, they'll
simply fail because some of the images might be bad. But, I need to know
whether or not the images got processed or not. So, because an image
failure can literally lead to the whole Ruby script just failing, I'd
like to create a separate script that simply lists all of the files in
the input directory (separately from the processing script) and checks
to see if they all got processed or not. In DOS, I would use a "call"
statement. What's the equivalent in Ruby?
Thanks,
Peter
Hi,
Can someone please tell me how you can can call out another Ruby script?
I have a lot of image processing scripts. Sometimes, rarely, they'll
simply fail because some of the images might be bad. But, I need to know
whether or not the images got processed or not. So, because an image
failure can literally lead to the whole Ruby script just failing, I'd
like to create a separate script that simply lists all of the files in
the input directory (separately from the processing script) and checks
to see if they all got processed or not. In DOS, I would use a "call"
statement. What's the equivalent in Ruby?
Thanks,
Peter
I am not sure I understand the requirement from this. Why do you need
a separate script? What stops you from invoking a method in the same
script that does the check?
Kind regards
robert
···
2009/8/10 Peter Bailey <pbailey@bna.com>:
I have a lot of image processing scripts. Sometimes, rarely, they'll
simply fail because some of the images might be bad. But, I need to know
whether or not the images got processed or not. So, because an image
failure can literally lead to the whole Ruby script just failing, I'd
like to create a separate script that simply lists all of the files in
the input directory (separately from the processing script) and checks
to see if they all got processed or not.
Just load the other script in the usual way and call something in it.
Example:
script1.rb:
def doStuff(x)
end
script2.rb:
require 'script1'
list_of_files = # whatever
list_of_files.each do |a_file|
begin
doStuff(a_file)
rescue
puts "#{a_file} didn't process correctly"
end
end
m.
??? m.
···
Peter Bailey <pbailey@bna.com> wrote:
Hi,
Can someone please tell me how you can can call out another Ruby script?
I have a lot of image processing scripts. Sometimes, rarely, they'll
simply fail because some of the images might be bad. But, I need to know
whether or not the images got processed or not. So, because an image
failure can literally lead to the whole Ruby script just failing, I'd
like to create a separate script that simply lists all of the files in
the input directory (separately from the processing script) and checks
to see if they all got processed or not. In DOS, I would use a "call"
statement. What's the equivalent in Ruby?
Thanks,
Peter
I have a lot of image processing scripts. Sometimes, rarely, they'll
simply fail because some of the images might be bad. But, I need to know
whether or not the images got processed or not. So, because an image
failure can literally lead to the whole Ruby script just failing, I'd
like to create a separate script that simply lists all of the files in
the input directory (separately from the processing script) and checks
to see if they all got processed or not.
I am not sure I understand the requirement from this. Why do you need
a separate script? What stops you from invoking a method in the same
script that does the check?
Kind regards
robert
This second script is the one that's doing the check. The first script
needs to process the images, meaning, it converts them to various other
formats. And, if the image processing fails (it's calling an outside
image processing utility), then, the whole Ruby script can simply fail,
too. If I have 50 files coming in, then, I'll need to know whether or
not those 50 files went to their proper destinations in their proper
formats. If the image processing fails for any reason, and the Ruby
script simply dies, too, then, I'll need to know that.
Thanks.
I have a lot of image processing scripts. Sometimes, rarely, they'll
simply fail because some of the images might be bad. But, I need to know
whether or not the images got processed or not. So, because an image
failure can literally lead to the whole Ruby script just failing, I'd
like to create a separate script that simply lists all of the files in
the input directory (separately from the processing script) and checks
to see if they all got processed or not.
I am not sure I understand the requirement from this. Why do you need
a separate script? What stops you from invoking a method in the same
script that does the check?
This second script is the one that's doing the check. The first script
needs to process the images, meaning, it converts them to various other
formats. And, if the image processing fails (it's calling an outside
image processing utility), then, the whole Ruby script can simply fail,
too.
What about preventing that? I mean, you could make sure that it does
not stop processing even if the external program failed. You can even
catch an exit as a quick hack:
If I have 50 files coming in, then, I'll need to know whether or
not those 50 files went to their proper destinations in their proper
formats. If the image processing fails for any reason, and the Ruby
script simply dies, too, then, I'll need to know that.
But if the first script dies, there is no chance to invoke the second
script from it. Or do you want to start the second script and have
that call the first script? In any way I still do not see the need
for two scripts unless your Ruby interpreter could actually crash.