The ssh addon and HA are separate docker containers. A script that works while ssh'ed won't necessarily work from a shell command as each docker container has different things installed. In this case the problem is the HA CLI is unavailable in the HA container, it's only in the ssh container.
To do what you want your shell command would need to ssh to the ssh addon and run the script there. See the linked guide for how to set that up