never_had_a_name
never_had_a_name

Reputation: 93206

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 code 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?

Upvotes: 0

Views: 2048

Answers (2)

krunal shah
krunal shah

Reputation: 16339

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

Upvotes: 1

Sebastian Brózda
Sebastian Brózda

Reputation: 879

try in a controller:

Dir.chdir path_typed_in_by_user
@out = system `ls -la` # !! look here !! " change `

in a view:

Upvotes: 1

Related Questions