1

I'm currently trying to append this line to the end of a file

 zone_text = 'zone \"domain.com\" { type master; file \"/etc/bind/zones/domain.com\";};' add_zone_file = subprocess.Popen( ['ssh', NAMESERVERS[0], '/bin/echo', '"{}"'.format(zone_text), '>>', '/etc/bind/named.conf.local'], stdout=subprocess.PIPE ) 

But when I inspect the file it outputs this into it

zone domain.com { type master; file /etc/bind/zones/domain.com;}; 

And I need it to output this

zone "domain.com" { type master; file "/etc/bind/zones/domain.com";}; 

1 Answer 1

1

Please consider using shlex.quote(). It should help. There's also an option to use shell=True to Popen(), but this one has some negative security aspects.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.