zoukankan      html  css  js  c++  java
  • RUN命令说明

    备忘单:
    
    
    执行一个命令解析它的输出:
    
    run($command, %options)
    
    运行一个远程命令返回它的输出
    
    task "test01", sub {
       my $out = run "pwd",
       cwd=>'/home/mqm/perl/';
       say $out;
    };
    
    cmd --  命令的工作目录
    
    only_if - Executes the command only if the condition completes successfully.
    
    执行命令只有条件成功,才会执行run
    
    [root@node01 my-first-rex-project]# rex -H 192.168.137.2 test02
    [2019-06-18 12:55:02] INFO - Running task test02 on 192.168.137.2
    $VAR1 = {
              'auto_die' => 0
            };
    idd: Command not found.error-------------------
    127
    -------------------
    [2019-06-18 12:55:02] INFO - All tasks successful on all hosts
    
    
    unless - Executes the command only unless the condition completes successfully.
    
    
    [root@node01 my-first-rex-project]# rex -H 192.168.137.2 test02
    [2019-06-18 12:57:21] INFO - Running task test02 on 192.168.137.2
    $VAR1 = {
              'auto_die' => 0
            };
    idd: Command not found.error$VAR1 = {
              'auto_die' => undef,
              'unless' => 'idd'
            };
    /root
    [2019-06-18 12:57:22] INFO - All tasks successful on all hosts
    [root@node01 my-first-rex-project]# 
    
    
    
    task "task03", sub {
       run "extract-something",
         command     => "pwd",
         only_notified => TRUE;
    };
    
    
    
    If you only want to run a command in special cases, you can queue the command
    and notify it when you want to run it.
    
     task "prepare", sub {
       run "extract-something",
         command     => "tar -C /foo -xzf /tmp/foo.tgz",
         only_notified => TRUE;
    
       # some code ...
    
       notify "run", "extract-something";  # now the command gets executed
     };
     
     
  • 相关阅读:
    Java 实现常见内排序
    markdown基本语法
    HashMap (JDK1.8) 分析
    jQuery总结
    JS 数组 常用方法
    CSS样式 解决文字过长显示省略号问题
    Python中的 __name__属性的含义和作用
    http协议详细介绍
    Http和Https的区别
    爬虫——requests库使用方法
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348709.html
Copyright © 2011-2022 走看看