Package net.neoremind.sshxcute.core

Examples of net.neoremind.sshxcute.core.SSHExec


                String login = ComboAction.getLogin();
                String pass = ComboAction.getPass();
               
                ConnBean cb = new ConnBean(ip, login, pass);
                SSHExec.setOption(IOptionName.SSH_PORT_NUMBER, 9022);
                SSHExec ssh = SSHExec.getInstance(cb);         
               
                CustomTask sampleTask = new ExecCommand("echo 123");
                Font font = new Font("Verdana", Font.BOLD, 17);
                LogIp log = new LogIp();
               
                if(source==restart_p2s)
                {
                        if(answer==JOptionPane.YES_OPTION)
                        {

                                try
                                {
                                        ssh.connect();
                                        net.neoremind.sshxcute.core.Result res = ssh.exec(sampleTask);
                                        if (res.isSuccess)
                                        {
                                                label_restart_p2s_OK.setFont(font);
                                                label_restart_p2s_OK.setForeground(new Color(34,139,34));
                                                label_restart_p2s_OK.setText("OK");
                                                label_restarting.setText(null);
                                                label_restart_p2s.setText("Restart o: " + dt.format(date));
                                               
                                                log.setAction(1);
                                        }
                                        else
                                        {
                                          label_restart_p2s_FAIL.setFont(font);
                                          label_restart_p2s_FAIL.setForeground(new Color(220,20,60));
                                          label_restart_p2s_FAIL.setText("FAIL");
                                          label_restarting.setText(null);
                                          label_restarting.setText("Blad polaczenia z serwerem");
                                         
                                          log.setAction(2);
                                        }
                                }
                               
                                catch (TaskExecFailException e1)
                                {
                            System.out.println(e1.getMessage());
                            e1.printStackTrace();
                                }
                                catch (Exception e1)
                                {
                            System.out.println(e1.getMessage());
                            e1.printStackTrace();
                                }
                                finally
                                {
                                LogIp.logExecution();
                                    ssh.disconnect();  
                                }
                               
                        }
                }
                else if(source==restart_dialer)
                {
                        if(answer==JOptionPane.YES_OPTION)
                        {

                                try
                                {
                                        ssh.connect();
                                        net.neoremind.sshxcute.core.Result res = ssh.exec(sampleTask);
                                        if (res.isSuccess)
                                        {
                                                label_restart_dialer_OK.setFont(font);
                                                label_restart_dialer_OK.setForeground(new Color(34,139,34));
                                                label_restart_dialer_OK.setText("OK");
                                                label_restarting.setText(null);
                                                label_restart_p2s.setText("Restart o: " + dt.format(date));
                                               
                                                log.setAction(3);
                              }
                              else
                              {
                                        label_restart_dialer_FAIL.setFont(font);
                                        label_restart_dialer_FAIL.setForeground(new Color(220,20,60));
                                        label_restart_dialer_FAIL.setText("FAIL");
                                        label_restarting.setText(null);
                                        label_restarting.setText("Blad polaczenia z serwerem");
                                       
                                        log.setAction(4);
                              }
                                }
                               
                                catch (TaskExecFailException e1)
                                {
                            System.out.println(e1.getMessage());
                            e1.printStackTrace();
                                }
                                catch (Exception e1)
                                {
                            System.out.println(e1.getMessage());
                            e1.printStackTrace();
                                }
                                finally
                                {
                                    LogIp.logExecution();
                                    ssh.disconnect();      
                                }
                        }
                }
                else if(source==restart_pause)
                {
                        if(answer==JOptionPane.YES_OPTION)
                        {

                                try
                                {
                                        ssh.connect();
                                        net.neoremind.sshxcute.core.Result res = ssh.exec(sampleTask);
                                        if (res.isSuccess)
                                        {
                                                label_restart_pause_OK.setFont(font);
                                                label_restart_pause_OK.setForeground(new Color(34,139,34));
                                                label_restart_pause_OK.setText("OK");
                                                label_restarting.setText(null);
                                                label_restart_p2s.setText("Restart o: " + dt.format(date));
                                               
                                                log.setAction(5);
                              }
                              else
                              {
                                        label_restart_pause_FAIL.setFont(font);
                                        label_restart_pause_FAIL.setForeground(new Color(220,20,60));
                                        label_restart_pause_FAIL.setText("FAIL");
                                        label_restarting.setText(null);
                                        label_restarting.setText("Blad polaczenia z serwerem");
                                       
                                        log.setAction(6);
                              }
                                }
                               
                                catch (TaskExecFailException e1)
                                {
                            System.out.println(e1.getMessage());
                            e1.printStackTrace();
                                }
                                catch (Exception e1)
                                {
                            System.out.println(e1.getMessage());
                            e1.printStackTrace();
                                }
                                finally
                                {
                                    LogIp.logExecution();
                                    ssh.disconnect();      
                                }
                        }
                }
                else
                {
View Full Code Here

TOP

Related Classes of net.neoremind.sshxcute.core.SSHExec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.