Manish Shrivastava
Manish Shrivastava

Reputation: 32070

I need to show formatted output as it shows in ssh screen

In Ruby or in Rails:- I need to show output from below code formated as it shows in command prompt.

require 'net/ssh'

Net::SSH.start( hostname, username, :password => password ) do|ssh|

result = ssh.exec!('ls -ltr')

puts result

end

Let me know how is it possible?

Command (ls -ltr) is dynamic and currently output is:

total 257140 drwxrwxr-x 8 folderabc folderabc 4096 Set 4 2010 sources drwxrwxr-x 13 folderabc folderabc 4096 Set 4 2010 teste -rwxrwxr-x 1 folderabc folderabc 72 Set 7 2010 clean_memory -rw-rw-r-- 1 folderabc folderabc 263012352 Mar 17 2011 ngforms_production.sql -rw-rw-r-- 1 folderabc folderabc 21 Jun 23 2011 phps.php drwxrwxr-x 15 folderabc folderabc 4096 Jun 30 2011 ngforms -rw-rw-r-- 1 folderabc folderabc 751 Jul 1 2011 ngforms_word.sql -rw-rw-r-- 1 folderabc folderabc 31 Jul 5 2011 test.php drwxrwxr-x 5 folderabc folderabc 4096 Nov 4 10:52 dump drwxrwxrwx 2 folderabc folderabc 4096 Jan 13 00:00 mysqlbackup

Upvotes: 0

Views: 90

Answers (1)

Arun Kumar Arjunan
Arun Kumar Arjunan

Reputation: 6857

Try using the <pre> tag. Also make sure that the font you use is one of the monospace fonts like CourierNew.

<pre><%= result %></pre>

Upvotes: 2

Related Questions