I am trying to make a python program write to a root protected file. This is using the python notify module. I am trying to get the program to use the registered endpoint.
On the console these both work and write sometext in the file /root/.config/notify-run:

```
sudo sh -c 'echo sometext >> /root/.config/notify-run'
echo sometext | sudo tee /root/.config/notify-run

```

Now in python I tried:

```
link = 'the endpoint'
command = ['sudo sh -c "echo', link, ' >>/root/.config/notify-run"']
subprocess.call(command, shell=True)

```

This returns:

```
syntax error unterminated quoted string

```

And trying:

```
link = 'the endpoint'
command = ['echo', link, '| sudo tee -a /root/.config/notify-run'] 
subprocess.call(command, shell=True)

```

Returns no error but does not write the endpoint in the file.

Anyone knows how to fix this? using this or other code that does the same as i am trying to do over here?