0

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?

never_had_a_name
  • 90,630
  • 105
  • 267
  • 383

2 Answers2

1

try in a controller:

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

in a view:

1

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
Community
  • 1
  • 1
krunal shah
  • 16,089
  • 25
  • 97
  • 143