I’m trying to run the following shell command but keep coming up with the below error message;
Shell Command;
ssh -i /.ssh/id_rsa -o 'StrictHostKeyChecking=no' ######@10.10.10.195 'sudo docker ps --format "table {{.ID}},{{.Names}},{{.Image}}" > /home/######/docker/homeassistant/csv/container.csv'
Error Message:
Error rendering command template: TemplateSyntaxError: unexpected '.'
It seems to be the period in the table names that is causing the issue (i think) as removing them allows the command to run but just pulls back the commas in between. If I run the code from within the container it works fine as is and gives the desired result, it just won’t run from the Home Assistant shell command.
Is there a workaround or alternative way to execute this as I want it to run on a schedule.
Full error code from HA;
Error rendering command template: TemplateSyntaxError: unexpected '.'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 318, in ensure_valid
self._compiled_code = self._env.compile(self.template) # type: ignore[no-untyped-call]
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1469, in compile
cached = self.template_cache[source] = super().compile(source)
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 638, in compile
self.handle_exception(source=source_hint)
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "<unknown>", line 1, in template
jinja2.exceptions.TemplateSyntaxError: unexpected '.'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/shell_command/__init__.py", line 48, in async_service_handler
rendered_args = args_compiled.async_render(
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 362, in async_render
compiled = self._compiled or self._ensure_compiled(limited)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 539, in _ensure_compiled
self.ensure_valid()
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 320, in ensure_valid
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TemplateSyntaxError: unexpected '.'