简体   繁体   中英

'mutt' does not show full subject

I use following shell script to send email. But the subject of email always shows "This" instead of "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";

Move your single quote.

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";'

EDIT: I put the variable out of the quotes. The main thing is spaces are covered.

First start with what you want the remote command to look like, with bare minimal quoting:

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

There are only a couple of things you need to quote to have them passed literally to the remote shell: the pipe character, and quotes around the subject to make the spaces not split it into separate arguments to mutt.

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"'";

With the longer command, do the same thing:

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'

(only with the variables substituted).

Here, a few things need to be quoted:

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"'"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM