0

Many config files use the hash sign # to mark the beginning of a comment. How do I set values that contain such a sign without it being interpreted as a comment?

[edit]
actually, it seems to be a real problem. See https://superuser.com/questions/431539/special-characters-in-ssmtp-password for more info

2 Answers 2

2

You need to either escape it:

\#

or quote it

"#"

or

'#'

For some config file formats you won't need that as it is only considered a comment when the # is at the beginning of a line, e.g. Apache config files.

Lines that begin with the hash character "#" are considered comments, and are ignored

8
  • in this case, I am using the ssmtp software and I have a sharp in the AuthPass variable. Quoting or escaping does not work in this case neither for apache config files. May 21, 2019 at 13:56
  • 1
    You should not need to quote them for apache files: "Lines that begin with the hash character "#" are considered comments, and are ignored.".
    – pLumo
    May 21, 2019 at 13:57
  • 1
    it should be the same for ssmtp but it seems not to be May 21, 2019 at 14:01
  • 1
    sorry, I cannot help you with this.
    – pLumo
    May 21, 2019 at 14:06
  • 1
    I found this : superuser.com/questions/431539/… May 21, 2019 at 14:15
0

I found a workaround: in my case, I had to feed the variable directly in the command line arguments of the program.

e.g.

ssmtp -ap "PasswordWith#InIt" ...

it might not work for other programs.

2
  • 1
    1 issue: this WILL reveal the password to the system. ps -ef | grep ssmtp will show it
    – Rinzwind
    May 21, 2019 at 14:46
  • You're right, it's not secure. Using an environment variable to store the password is slightly better, but if security is the problem, you would rather use a password manager. May 21, 2019 at 16:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .