Calling Bird2 from Python script fails

Inrin inrin at caesia.net
Sat Dec 3 15:09:40 CET 2022


Hi Stavros,

On Mon, Nov 28, 2022 at 03:08:59PM +0000, Stavros Konstantaras via Bird-users wrote:
>And after closing the output file I proceed on calling subprocess with the "birdc configure" command.

You might consider sending the command directly to the control socket, e.g. (no error handling!):

```python
import socket

with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
     sock.connect('/run/bird/bird.ctl')
     sock.send(b'configure\n')
     # Assumption your config is under /etc/bird.conf
     assert sock.recv(4096) == b'0002-Reading configuration from /etc/bird.conf\n0003 Reconfigured\n'
```

Best Regards
Inrin


More information about the Bird-users mailing list