I have defined a shell command that includes two curl commands separated by a semicolon. If I issue this compound command directly in the Home Assistant’s terminal, it works without issue. However, if I call this shell command from inside an automation it does not work. But it works fine if the shell command only includes one of the two curl commands. So I think the problem is with defining a shell command that includes two terminal commands separated by a semicolon. What should I do to get around the problem?
My shell command looks like this:
curl -X POST http://localhost:1984/api/streams\?dst\=front_north\&src\=ffmpeg:/media/trespass1.m4a%23audio\=pcm%23input\=file ; curl -X POST http://localhost:1984/api/streams\?dst\=front_south\&src\=ffmpeg:/media/trespass1.m4a%23audio\=pcm%23input\=file
You can’t run multiple commands. From the documentation:
When using templates, shell_command runs in a more secure environment which doesn’t allow any shell helpers like automatically expanding the home dir ~ or using pipe symbols to run multiple commands.
Or you could create a shell script to do what you need and then simply call that script. That’s what I have done. You can pass variables to it, the whole works. It’s great.