I'm writing a utility method in Ruby to run shell commands on a remote server.
Here's what I have so far...
def exec_remotely(command)
remote_command = "ssh -t #{@config['remote_username']}@#{@config['target_server']} '#{command}'"
puts "------> Executing:"
puts " #{remote_command}"
output = `#{remote_command}`
output.lines.each do |line|
puts " #{line}"
end
end
The effect I want on the console is this:
------> Executing:
ssh -t user@host.com 'ls -alh'
Connection to host.com closed.
total 8.7M
drwx------ 10 username username 4.0K Sep 5 18:11 .
drwxr-xr-x 3 root root 4.0K Aug 26 21:18 ..
-rw------- 1 username username 1.6K Sep 5 17:47 .bash_history
-rw-r--r-- 1 username username 18 Dec 2 2011 .bash_logout
-rw-r--r-- 1 username username 48 Aug 27 02:52 .bash_profile
-rw-r--r-- 1 username username 353 Aug 27 03:05 .bashrc
# etc...
But what I'm getting instead is this...
------> Executing:
ssh -t user@host.com 'ls -alh'
Connection to host.com closed.
total 8.7M
drwx------ 10 username username 4.0K Sep 5 18:11 .
drwxr-xr-x 3 root root 4.0K Aug 26 21:18 ..
-rw------- 1 username username 1.6K Sep 5 17:47 .bash_history
-rw-r--r-- 1 username username 18 Dec 2 2011 .bash_logout
-rw-r--r-- 1 username username 48 Aug 27 02:52 .bash_profile
-rw-r--r-- 1 username username 353 Aug 27 03:05 .bashrc
# etc...
How can I get everything to line up vertically? (Except for the "------>". That's supposed to start at the left edge.)