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

  • 相关阅读:
    React 生命周期及setState原理分析
    React Vue Angular 对比
    盒模型(一)
    CSS尺寸 rem与em原理与区别(二)
    HTTP 状态码
    React渲染机制
    HTTP三次握手四次挥手
    Java常见算法
    SharedPreferences存储数据
    解决ListView滑动上下出现阴影
  • 原文地址:https://www.cnblogs.com/lindows/p/7133515.html
Copyright © 2011-2022 走看看