Pregunta

I've a script that send an email to user. I need to add a variable (name of new user) to subject. My example:

a="John";echo|mutt -s welcome$a -e 'my_hdr From:info@example.com <info@example.com>' test@example.com

Obviously this runs but the subject is: welcomeJohn. I need a space between welcome and John. A real space doesn't works, change from a="John" to a=" John" doesn'run... Either programmatically add a space to variable or put all subject to variable.

¿Fue útil?

Solución

Try enclosing subject with double quotes

a="John Foo";echo|mutt -s "welcome $a" -e 'my_hdr From:info@example.com <info@example.com>' test@example.com

It will send a mail with subject welcome John Foo. Change your command for required subject. You are free put spaces anywhere in subject or variable value now.

Note: It's standard practice to specify any input, variable for command line arguments to linux commands with proper quotes to mitigate white space issues.

'' for literal string

"" for variable substitutions

Otros consejos

Have you tried

mutt -s "welcome $a"

instead of the current

mutt -s welcome$a
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top