package com.svlada;

import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

import com.jcraft.jsch.Session;
import com.svlada.ssh.ExecCommand;
import com.svlada.ssh.PublicKeySshSession;
import com.svlada.ssh.logger.JschLogger;

/**
 * Demonstrate public key authentication and execution of simple command over SSH.
 * 
 * @author vladimir.stankovic (svlada@gmail.com)
 *
 */
public class App {
	
	static final Logger logger = Logger.getLogger(App.class);
	
	public static void main(String[] args) {
		
		Properties config = App.getConfig(args);
		
		final Session session = new PublicKeySshSession.Builder()
			.host(config.getProperty("host"))
			.username(config.getProperty("username"))
			.privateKeyPath(config.getProperty("privateKeyPath"))
			.port(Integer.parseInt(config.getProperty("port")))
			.logger(new JschLogger())
			.build();
		
		if (session == null) {
			System.exit(-1);
		}
		
		ExecCommand command = new ExecCommand();
		command.execute(session, "echo \"Sit down, relax, mix yourself a drink and enjoy the show...\" >> /tmp/test.out");
		
	}
	
	public static Properties getConfig(String[] args) {
		String profile = "local";
		
        if (args != null && args.length > 0) {
        	profile = args[0];
        }
        
        Properties properties = new Properties();
        
        try {
			properties.load(App.class.getClassLoader().getResourceAsStream("config/" + profile + "/ssh.config"));
		} catch (IOException e) {
			logger.error("Failed to load properties.", e);
			return null;
		}
        
        return properties;
	}

}

@@ -1180,24 +1180,18 @@
 al%22;%0A%09%09%0A
-        
+%09%09
 if (args
@@ -1221,24 +1221,18 @@
  %3E 0) %7B%0A
-        
+%09%09
 %09profile
@@ -1243,24 +1243,18 @@
 rgs%5B0%5D;%0A
-        
+%09%09
 %7D%0A      
@@ -1256,24 +1256,18 @@
        %0A
-        
+%09%09
 Properti
@@ -1309,24 +1309,18 @@
        %0A
-        
+%09%09
 try %7B%0A%09%09
@@ -1529,24 +1529,18 @@
        %0A
-        
+%09%09
 return p

Fix indentation.