AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 894597
Accepted
Francesc Guasch
Francesc Guasch
Asked: 2018-01-30 04:22:30 +0800 CST2018-01-30 04:22:30 +0800 CST 2018-01-30 04:22:30 +0800 CST

如何使用 rex 创建目录

  • 772

rex如果它不存在,我想创建一个目录。我读了这个 ,但我找不到怎么做。

如果我发送没有目录的文件,我会收到此错误:

ERROR - upload: /usr/local/path/file.ext is not writable

有什么提示吗?

operations-orchestration
  • 1 1 个回答
  • 103 Views

1 个回答

  • Voted
  1. Best Answer
    MacMartin
    2018-02-13T04:56:56+08:002018-02-13T04:56:56+08:00

    我认为 rex 书中的文档有点旧。

    请在此处查看https://www.rexify.org/docs/api/或(截至今天)此处的最新文档:
    https ://www.rexify.org/docs/api/1.4/rex/commands /file.pm.html#file-file_name-options-
    (它说的是版本 1.4,而当前的 cpan 版本是 1.6,但没关系)

    所以,用一个例子来回答你的问题:

    task "backuptask", group => "mygroup", sub { 
        #
        # 1.) define the Backup Dir (you could do it without this step)                                                                                                                        
        my $backupdir = "/tmp/backup";  
        #                                                                                                      
        # 2.) "ensure" that the file is a (existing) "directory"        
        file $backupdir, 
                ensure=> "directory", 
                owner => "myowner", 
                group => "mygroup", 
                mode => 700, 
                on_change => sub { say "File was changed";};
    
        #                                                                                                                                    
        # 3.) define Backup File                                                                                                                         
        my $currTimestamp = strftime('%y%m%d',localtime);                                                                                     
        my $backupfile = "$backupdir/somebackup$currTimestamp";
        #                                                                            
        # 4.) "ensure" the the file is "present" at the defined path
        file $backupfile, ensure=> "present";
    
        ...execute something here...
    
    }  ;                                                                                               
    
    • 1

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve