I know how to run a script from within Ruby. I usually use back ticks and they work fine. Recently we got request to feed one more argument to the script and problem happens here.
Originally, it looks like this: a global variable defined as:
SCRIPT = "/opt/customer/send_command.pl"
Then, we call
status =`"#{SCRIPT}" -c "ctl.pl qstatus"`
queue = `"#{SCRIPT}" -c "ctl.pl queue"`
Everything is fine. Now, there's one more parameter to feed in the script send_command.pl. So I changed global variable SCRIPT to:
SCRIPT = "/opt/customer/send_command.pl -p production"
And I use the same way to call that script:
status =`"#{SCRIPT}" -c "ctl.pl qstatus"`
But I got the error message:
sh: /opt/customer/send_command.pl -p production: not found
If I ditch SCRIPT variable, just call the script directly like:
status = `/opt/customer/send_command.pl -p production -c "ctl.pl qstatus"`
and it works as expected.
My question is why that happens and how to fix it? I guess I could just manually put -p production everywhere, but it's less ideal and very error prone.