【问题标题】:How to pass an argument to a perl script如何将参数传递给 perl 脚本
【发布时间】:2017-10-03 17:07:30
【问题描述】:
 my @return = `at now +3 days -f test2.pl myargument 2>&1`;

如何将该 myargument 传递给我的脚本 test2.pl?在该代码中,它返回一个错误。

【问题讨论】:

  • 这似乎不是 Perl 的问题,而是您使用 at 命令的问题。为了使调试更容易,最好在不引用 Perl 的情况下重新表述这个问题。例如尝试在两分钟内直接从命令行执行echo hello world。

标签: linux perl at-command


【解决方案1】:

根据我系统上at 的文档,它从-f 或STDIN 指定的文件中读取要执行的bourne shell 命令。

因此,以下应该可以解决问题:

`printf %s 'test2.pl myargument' | at now +3 days 2>&1`;

【讨论】:

  • 在我的脚本中,我需要发送一封电子邮件,该电子邮件需要稍后由 at 命令处理。在您的有效解决方案中,它首先发送电子邮件,然后创建作业。请帮忙
  • 我打赌你真的用过`test2.pl myargument | at now +3 days 2>&1`
猜你喜欢
  • 2012-12-08
  • 2014-04-08
  • 2015-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-02
相关资源
最近更新 更多