rails won"t execute a perl script in the same folder as the controller
I have a simple method
def execperl
system("perl myscript.pl")
redirect_to :controller => :mycontroller, :action => :index
end
Where I put this mycontroller (that contains index and execperl) in the same folder as the myscript.pl.
However, when I execute the method, it just go back to index, and when I see the console, no sign that myscript.pl is executed. If I execute myscript.pl manually using perl myscript.pl, it works just fine
How can I execute myscript.pl in the same location as the mycontroller file?
Thank y开发者_开发百科ou for any answer.
|edit I read that in the log, it is written "can't open perl script myscript.pl" No such file or directory.
Do I have to specify the location of the script in system("perl myscript.pl")? How can I do that?
Try doing:
system("/usr/bin/perl #{Rails.root}/app/controllers/myscript.pl")
Your current working directory is not the directory your script is in. The path to your script is something like:
File.join(File.dirname(__FILE__), "myscript.pl")
精彩评论