'mutt' 没有显示完整主题

'mutt' does not show full subject

我使用以下 shell 脚本发送电子邮件。但是电子邮件的主题总是显示 "This" 而不是 "This is L_1.R".

    program=("L_1" "L_2" "L_3" "L_4")
    subject="The job is finished"
    ssh -f c15-0330-01.ad.mtu.edu 'echo' "the job ${program[0]} is finished"   '|' 'mutt "zwang10@mtu.edu" -s' "This is "${program[0]}".R";

移动你的单引号。

ssh -f c15-0330-01.ad.mtu.edu 'echo' "the job ${program[0]} is finished" \
'|' 'mutt "zwang10@mtu.edu" -s "This is "'${program[0]}'".R";'

编辑:我把变量放在引号之外。最主要的是空格都被覆盖了。

首先从您希望远程命令的外观开始,使用最少的引号:

echo the job L_1 is finished | mutt zwang10@mtu.edu -s 'This is L_1.R'

只有几件事你需要引用才能让它们按字面意义传递给远程 shell:竖线字符,并在主题周围引号使空格不会将其拆分为单独的参数笨蛋。

program=("L_1" "L_2" "L_3" "L_4")
subject="The job is finished"
ssh -f c15-0330-01.ad.mtu.edu echo the job ${program[0]} is finished '|' mutt zwang10@mtu.edu -s "'"This is ${program[0]}.R"'";

使用更长的命令,做同样的事情:

cd $address && nohup Rscript ${program[0]}.R > ${program[0]}_sh.txt && echo the job ${program[0]} is finished | mutt zwang10@mtu.edu -s 'This is ${program[0]}.R'

(仅替换变量)。

在此,需要引用几点:

ssh -f c15-0330-01.ad.mtu.edu cd $address '&&' nohup Rscript ${program[0]}.R '>' ${program[0]}_sh.txt '&&' echo the job ${program[0]} is finished '|' mutt zwang10@mtu.edu -s "'"This is ${program[0]}.R"'"