Meeshoo Meeshoo - 5 months ago 8x
Ruby Question

How to call an external script with arguments?

I have a Ruby script that should call various scripts when the execution throws an error. How can I call a script with two arguments?

For the moment I am using the code below but I need to also send two arguments to

my_script = ""
%x( #{my_script})


You almost figured it out, just add the params:

my_script = ""
%x( #{my_script} #{arg1} #{arg2})

You may also want to check the return code:

if $? == 0
   puts "script executed successfully"
   puts "script returned an error, exit code: #{$?.to_s.split('exit ')[-1]}"