Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6653641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:17:40+00:00 2026-05-26T01:17:40+00:00

I am trying to run some commands remotely and SSH’ing in to the machine

  • 0

I am trying to run some commands remotely and SSH’ing in to the machine is not an option. What I am trying to do is setup a Sinatra app that runs some specific commands and streams the output through HTTP.

The sample action looks like this:

get "/log" do
  `tail -f some.log`
end

1 As far as I’ve read, I need to use Unicorn (or Mongrel) because Thin does not support streaming data
2 I think I need to pipe the commands output through some kind of IO ruby object

I almost know how to do (1) but have no idea how to achieve (2).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:17:41+00:00Added an answer on May 26, 2026 at 1:17 am

    If you’re on a synchronous server (i.e. Mongrel, Unicorn, not Thin), you can just return an IO object:

    require 'sinatra'
    
    get '/log' do
      content_type :txt
      IO.popen('tail -f some.log')
    end
    

    If that doesn’t work (if you’re on Thin, for instance), you can use the new streaming API:

    require 'sinatra'
    
    get '/log' do
      content_type :txt
      IO.popen('tail -f some.log') do |io|
        stream do |out|
          io.each { |s| out << s }
        end
      end
    end
    

    You can also use the bcat gem, which will colorize your output, if it contains ANSI color codes:

    require 'sinatra'
    require 'bcat'
    
    get '/log' do
      command = %[tail -f some.log]
      bcat = Bcat.new(command, :command => true)
      bcat.to_app.call(env)
    end
    

    Note: For infinitely running process you’ll have to take care of killing the process yourself if someone closes the connection. With the first solution some servers might take care of that for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run some commands in paralel, in background, using bash. Here's what
I am trying to run some Scala code on my OSX machine and keep
I am trying to run some unix commands from my java code. I am
I have a set of commands that I'd like to run and do some
I'm trying to write a shell script that, when run, will set some environment
After connecting to server, I run some commands on server and then trying to
Im trying to write a program that runs some shell commands wit emulated user
I'm trying to run some queries to get rid of XSS in our database
I am trying to run some unit tests in a C# Windows Forms application
I'm trying to run some python code under Apache 2.2 / mod_python 3.2.8. Eventually

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.