Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 shell 脚本,我想调用一个 perl 脚本来进行一些计算,一旦调用 perl,我希望 perl 处理它,并且在返回时我希望它返回的不是退出代码,而是一个返回 shell 脚本的字符串?我怎样才能做到这一点?
这是我在 shell 脚本 VAR=$(perl Test.pl) 中调用 perl 的简单代码
快速而肮脏的方法是让 perl 脚本print将信息发送到 STDOUT,然后在您的 Shell 脚本中通过反引号或就像您所做的那样调用它。沿着
print
VAR=`perl Test.pl`
这会将 perl 脚本打印到 STDOUT 的所有内容放入 VAR。