I'm writing a script to automate Let's Encrypt in PowerDNS,(this is a simple bash shell script to be run on debian)

Certbot runs and calls the script, feeding to it the variable: $CERTBOT_VALIDATION

I read a thread already here which shows the need for '"content"' – notice the single quote ' and the double quote ". (i've tried this in a different iteration of the code to no avail)  I'm struggling to output the expanded variable inside quotes, here is one way i tried:

pdnsutil add-record Example.com _acme-challenge txt 120 "\"%s\""  "$CERTBOT_VALIDATION"

However, to output that from bash, I must add a \ before the ".

I want the output command to be as follows:

 pdnsutil add-record Example.com _acme-challenge txt 120 "content"

What is the best way to do this?

whatever is currently being output is erroring with:

Error: Parsing record content (try 'pdnsutil check-zone'): Data field in DNS should start with quote (") at position 0 of ''yXtgt_2vlnrF7j2V-eTJZuSjXbswsGN97TQ0Zp3IynM''
  • What is wrong with escaping double quotes ... ? Apr 5, 2020 at 2:02
  • What language is your script?
    – L.Ray
    Apr 5, 2020 at 2:09
  • 1
    Quoting is hard, but I feel that you’re making it harder than you need to. I also feel that you’re not telling us everything — maybe because you think it’s too obvious? Are you trying to run a command, or are you writing a script whose job is to create a second script? You say, “I want the output command to be as follows”, and show a line that doesn’t have any single quotes in it — so why are you even talking about single quotes? It looks like you have a solution; why isn’t it good enough? What do you need help with? Apr 5, 2020 at 4:00
  • Please do not respond in comments; edit your question to make it clearer and more complete. Apr 5, 2020 at 4:00

1 Answer 1


i'll provide an update as a potential answer for anyone who comes across this in the future.

when running the certbot command:

certbot certonly --manual --preferred-challenges=dns --manual-auth-hook /etc/letsencrypt/customScripts/authenticator.sh -d *.example.com --dry-run

the script authenticator.sh is now:

pdnsutil add-record example.com _acme-challenge txt 120 $new2
echo $new2 > output.log
# Sleep to make sure the change has time to propagate over to DNS
sleep 25

this works, concatenating the variables as strings to add the double quotes. output.log shows the variable was

cat output.log 

and certbot reports:

certbot certonly --manual --preferred-challenges=dns --manual-auth-hook /etc/letsencrypt/customScripts/authenticator.sh -d *.example.com --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for example.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.

Are you OK with your IP being logged?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y
Output from authenticator.sh:
New rrset:
_acme-challenge.example.com. IN TXT 120 "RipQQbHO5pG95nzJjouCgTXJMrGTbLKQ5XsV5Zgn7uI"

Error output from authenticator.sh:
Apr 05 10:51:41 Reading random entropy from '/dev/urandom'
Apr 05 10:51:41 gmysql Connection successful. Connected to database 'pdns' on ''.
Apr 05 10:51:41 gmysql Connection successful. Connected to database 'pdns' on ''.

Waiting for verification...
Cleaning up challenges

 - The dry run was successful.

so this seems to have solved it.

You must log in to answer this question.

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