• 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
     };
     
     
  • 相关阅读:
    OpenCV 轮廓填充drawContours函数解析
    C++ MultiByteToWideChar和WideCharToMultiByte用法详解
    删除后缀dll文件,无需下载软件
    MYSQL误删除DELETE数据找回
    神经网络减少GPU显存占用的技术
    keras tensorflow 获取某层输出和层内参数的值
    聚光灯矩阵
    tf.linalg.band_part 和 tf.matrix_band_part
    机器学习,BootStrap
    极大团算法思路小记
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348709.html
Copyright © 2020-2023  润新知