html - Sinatra executing ls on sever side -
i trying show in chrome using sinatra, result of ls
. explorer gets in "connecting..." loop.
my code is:
require 'rubygems' if ruby_version < "1.9" require 'sinatra/base' #this webservice launch gamma project #using request @ principal webpage class myapp < sinatra::base '/' result = exec "ls" puts result end end
i not sure of puts
, think maybe not apropiate method. happening , how can solve it?
ps: in explorer used localhost.com:4567/
use backticks ( ` ) instead of kernel#exec command. former returns string can use in ruby process. latter throws execution context new process , has no return value.
get '/' result = %x`ls` puts result end
note call puts
not nice , you'll want format or parse/manipulate further. @ least you'll can use.
Comments
Post a Comment