I wanna run a ruby script which will be invoked by a method aftest of a controller.
when excuting controlle we know the current path is at the root of project.
FullScanTest.rb : the script i wanna invoke.
i can run the following command in bash shell , but can not invoked in rails
ruby ./public/ruby_lib/af/FullScanTest.rb -i 172.16.178.178 -s 25_10_1 -f auto
so i wrote a simple ruby script , which only reply a string . it did work~
ruby ./public/ruby_lib/af/test.rb
it works both on bash-shell and rails.
so what the problem?
permission? setting ?
Thanks you all in advance~
is there anyway to get the error output when we invoked a script on ROR ,
i think it doesn’t show the error msg.
i found the ruby script stop at require ‘mechanize’ and ‘nokogiri’.(so i mark them ~ they won’t be used in my app)
however the script also stop at somewhere not in expectaion ,
is there any limit to run a script?
the script will run for many hours.
i can execute the command ruby ./public/ruby_lib/af/FullScanTest.rb -i 172.16.178.178 -s 25_10_1 -f auto under prj_root
require 'open-uri'
require 'rubygems'
require 'mechanize'
require 'logger'
require 'time'
require 'nokogiri'
require 'pp'
**
is there anyone to show error , when i call a ruby script by a controller?
it’s hard for me to debug, it didn’t show any information.
**
def aftest
af_lib="./public/ruby_lib/af/"
prog="FullScanTest.rb"
prog2="test.rb"
params="-i 172.16.178.178 -s 25_10_1 -f auto "
cmd = " ruby #{af_lib}#{prog} #{params} "
@cmd = %x[ echo #{cmd} ]
res1 = %x[ ruby #{af_lib}#{prog} ]
res2 = %x[ ruby #{af_lib}#{prog2} #{params} --force 2>&1 ]
@res1 = "#{res1}"
@res1 = "#{res2}"
end
i use the view to show the output , but it didn’t show any errors
<h1>Af test lala</h1>
<%= form_tag :action => 'update', :id => @some_object %>
<%= form_tag( { :action => :save, }, { :method => :post }) %>
<h2>Command</h2>
<%= @cmd %>
<h2>Results</h2>
<%= @res1 %>
<h3>H3</h3>
<%= @res2 %>
How are you calling the script. Seeing as the the only difference between the script that works and the script that doesn’t, is the fact that the script that doesn’t work has ARGUMENTS???
Do you use system to call the script?
i.e.
or even better