我正在尝试从另一个脚本中调用脚本。这个想法是程序应该接收直接从unix邮件发送到stdin的电子邮件,然后解析一些东西并将其发送到新脚本。
我无法访问新脚本。但是,仅当脚本直接接受电子邮件时才会出现此问题。如果我在其中捕获文件,则没有问题,它会找到新脚本。
IE:如果我有一个名为“email.txt
”的测试文件,我执行命令:
cat email.txt | ./receiveEmail.sh
然后脚本调用工作正常。
但如果receiveEmail.sh
直接收到电子邮件,则无法调用新脚本。我知道这是失败的原因,因为我得到了脚本一直工作到它尝试调用新脚本的日志。
--------receiveEmail.sh----------
#!/bin/bash
###do some stuff to parse the stdin coming in and get variable $subject and $body
issue=`. /home/dlaf/bin/makeissue.sh` ->>>> this is the line that doesn't seem to work when the input is straight from the email rather than from a txt file i send it.
我很困惑。我想这可能是因为我错过了路径的某些部分?也许收到的电子邮件不知道我的完整路径究竟是什么?我不确定,因为当我输入命令行echo $LD_LIBRARY_PATH
时,我只是得到一个空行,所以我认为它甚至没有设置所以我不知道这可能是一个什么问题
答案 0 :(得分:0)
使用Bash将输出保存到变量时,我通常会这样做
read issue < <(~/bin/makeissue.sh)
echo "$issue"
如果输出是多行,则可以执行此操作
read -d'' issue < <(~/bin/makeissue.sh)
echo "$issue"
或者
mapfile issue < <(~/bin/makeissue.sh)
echo "${issue[@]}"