   params = params.parse()
   config params.config, (err, config) ->
     # Open readline
-    rl = readline.createInterface process.stdin, process.stdout
-    rl.setPrompt ''
-    rl.on 'SIGINT', process.exit
+    rl = null
+    init = ->
+      return unless process.stdout.isTTY
+      rl = readline.createInterface process.stdin, process.stdout
+      rl.setPrompt ''
+      rl.on 'SIGINT', process.exit
+    write = (msg) ->
+      unless rl
+      then process.stdout.write msg
+      else rl.write "#{styles.final_status_error err.stack?.trim() or err.message}\n"
+    refresh = (multi) ->
+      return unless rl
+      rl.cursor = 0
+      rl.line = ''
+      rl._refreshLine() if multi and not multihost
+    close = ->
+      return unless rl
+      rl.close()
     # Set styles
     styles =
       fqdn: colors.cyan.dim

      .on 'middleware_skip', (middleware) ->
        return unless middleware.header?
        line = ''
        line += pad "#{styles.fqdn ctx.config.host}", hostlength
        line += pad "#{styles.label middleware.header}", 40
        line += pad "#{styles.status_skip 'SKIPPED'}", 20
        rl.write line
        rl.write '\n'
      .on 'middleware_start', (middleware) ->
        return unless middleware.header?
        times[ctx.config.host] = Date.now()
        return if multihost
        line = ''
        line += pad "#{styles.fqdn ctx.config.host}", hostlength
        line += pad "#{styles.label middleware.header}", 40
        line += pad "#{styles.status_start 'WORKING'}", 20
        rl.write line
      .on 'middleware_stop', (middleware, err, status) ->
        return unless middleware.header?
        time = Date.now() - times[ctx.config.host]
        line = ''
        line += pad "#{styles.fqdn ctx.config.host}", hostlength
        line += pad "#{styles.label middleware.header}", 40
        statusmsg = if err then "#{styles.status_error middleware.label_error or 'ERROR'}"
        else if typeof status is 'string' then status

      final_status_error: colors.red
      final_status_success: colors.blue
    if err
      write "#{styles.final_status_error err.stack?.trim() or err.message}\n"
      process.exit()
    hostlength = 20
    for s in config.servers then hostlength = Math.max(hostlength, (s.shortname or s.host).length+2)
    multihost = params.hosts?.length isnt 1 and config.servers.length isnt 1
    times = {}
    multihost = true
    init()
    for k, v of config.styles
      styles[k] = if typeof v is 'string' then colors[v] else v
    run params, config
