Display terminal output on web browser?
Here is my case:
I want to use a web browser to connect to a Rails application that runs this example c开发者_StackOverflowode on the server side:
Dir.chdir path_typed_in_by_user
system "ls -la"
I want the output of "ls -la" to be displayed on the web browser.
Is this possible somehow?
This links may help you run command line command into ruby ...
http://zhangxh.net/programming/ruby/6-ways-to-run-shell-commands-in-ruby/
Calling shell commands from Ruby
http://blog.jayfields.com/2006/06/ruby-kernel-system-exec-and-x.html
%x[command].each do |f|
value = f
end
try in a controller:
Dir.chdir path_typed_in_by_user
@out = system `ls -la` # !! look here !! " change `
in a view:
精彩评论