Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9319903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:30:04+00:00 2026-06-19T03:30:04+00:00

I wanna run a ruby script which will be invoked by a method aftest

  • 0

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 %>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:30:06+00:00Added an answer on June 19, 2026 at 3:30 am

    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.

    system("./public/ruby_lib/af/FullScanTest.rb","-i","172.16.178.178","-s","25_10_1","auto")
    

    or even better

    path = "#{Rails.root}/public/ruby_lib/af/FullScanTest.rb"
    system(path,"-i","172.16.178.178","-s","25_10_1","auto")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanna run php script which has got curl on it. but following functions
i wanna using curl in php script and run it in command line mode.
In Ruby, you can capture a call to a method which is missing and
I wanna create a exe which has the Shell Script and Simple CPP file
I have a Database with some tables, I wanna to run a method in
I wanna run selenium tests from TeamCity using Maven at Linux server without display.
I wanna run two system activities one after another in specific order. now as
I have a project on intellij and now i wanna run it on intellinj
I wanna compile and run one copy of C++ codes on Windows and Linux.
I have an little script which logs users that login to my Pidgin/MSN account

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.