【发布时间】:2020-04-30 18:31:46
【问题描述】:
我在util.sh中有一些函数,我想调用util.sh中的函数并获取返回值。 有人知道怎么做吗?
util.sh
#!/bin/bash
sayhello()
{
echo $1 "hello"
}
我尝试使用以下命令在终端中调用该函数,但得到输出“找不到命令sayhello”:
sh /home/adnrew/code/test/util.sh sayhello test
并使用我的 perl 中的代码如下,
$returnvalue = system("/home/adnrew/code/test/util.sh sayhello test ");
也不行。
如何在我的 Perl 中调用 shell 脚本函数?
【问题讨论】:
-
要从 Perl 脚本中执行此操作,请参阅this question的答案