zoukankan      html  css  js  c++  java
  • loadrunner java ssh

    s

    D:\TestCase\20170703_docker_rongqiyun\tc_docker_ssh_docker_push\Actions.java

    /*
     * LoadRunner Java script. (Build: _build_number_)
     * 
     * Script Description: 
     *                     
     */
    
    import lrapi.lr;
    import java.io.IOException;
    import ch.ethz.ssh2.Connection;
    import ch.ethz.ssh2.Session;
    
    public class Actions
    {
        /*
            String server = "10.19.95.19";
            String server = "<ip>";  // 全局变量,loadrunner数据参数化会失败。必须放到下面局部变量public int action() throws Throwable {这里面参数化}
            String userName = "root";
            String password = "12345";
            String shell = "mkdir tangxje";
        */
    
        public void startPython(String hostname,String username,String password,String shell)throws Exception{  
             
              try
                {
                    Connection conn = new Connection(hostname);
                    conn.connect();
                    boolean isAuthenticated = conn.authenticateWithPassword(username, password);
                    if (isAuthenticated == false)
                        throw new IOException("Authentication failed.");
                    Session sess = conn.openSession();
                    sess.execCommand(shell);
                    
                    System.out.println("ExitCode: " + sess.getExitStatus());
                    sess.close();
                    conn.close();
                }
                catch (IOException e)
                {
                    e.printStackTrace(System.err);
                    System.exit(2);
                }
               
        }
    
        public int init() throws Throwable {
            return 0;
        }//end of init
    
    
        public int action() throws Throwable {
    
            String server = "<ip>";                
            String userName = "root";
            String password = "12345";
            String shell = "mkdir tangxje";    
    
            startPython(server, userName, password, shell);
    
            return 0;
        }//end of action
    
    
        public int end() throws Throwable {
            return 0;
        }//end of end
    }

    D:\TestCase\20170703_docker_rongqiyun\tc_docker_ssh_docker_push\ip.dat

    1 ip
    2 10.19.95.19
    3 

    end

  • 相关阅读:
    CSRF 1 (转)
    学习笔记-静态SQL和动态SQL
    学习笔记-oracle-PL/SQL-动态游标
    spring框架介绍以及简单使用
    SpringMvc的常用注解
    tcp的三次握手个四次挥手
    大量面试题
    Comparable和Comparator接口
    JVM介绍
    JVM类加载
  • 原文地址:https://www.cnblogs.com/lindows/p/7133515.html
Copyright © 2011-2022 走看看