【发布时间】:2010-09-09 10:16:32
【问题描述】:
我们可以在 perl 脚本中获取 shell 脚本吗??
示例: 方案一:
cat test1.sh
#!/bin/ksh
DATE=/bin/date
程序 2:
cat test2.sh
#!/bin/ksh
. ./test1.sh
echo `$DATE`
方案 3:
cat test3.pl
#!/usr/bin/perl
### here I need to source the test1.sh script
print `$DATE`'
如何在 perl 中获取 shell 以在我执行 test3.pl 时打印日期
谢谢 拉古
【问题讨论】:
-
有什么理由不想为此使用 Perl 的日期时间模块?
-
@ghostdog74 你甚至不需要模块。标量上下文中的
localtime函数生成几乎相同的字符串:perl -le 'print scalar localtime',您只需要获取时区,它们将是相同的。 -
嘿日期只是一个例子......它可以是代替日期的任何东西(ls,chown,echo .....)无论第一个文件中的命令是什么我需要来源到 perl;
标签: perl