How to call a script in config directory

I have a file called cast.sh in my config directory that runs a few catt commands. I usally call it by logging in and ./cast.sh.

Is there a way to execute that with an automation?

I’ve tried that. Do you have an example you could show?

There’s one in Shell Command’s documentation and many more if you search the forum:
https://community.home-assistant.io/search?q=shell_command

I think OP is looking to view contents of a file. My understanding is that she’ll command captures stdout to log but it is not available via template or front end. So in that case, she’ll command not a solution. The command line sensor might be a better solution.

Thanks. Im not trying to view contents of a file. The script just runs a few catt commands. Catt is a python app that casts pages to google hubs. Or if I could run this from within HA it would help. Ive tried the examples in searching btw.

catt -d 'Bathroom Display' cast_site http://10.1.99.111:8123/lovelace/home

Aahh. Thought “catt” was typo for “cat”.

You’ll need to provide full path to catt command. What is HA core running on?

I havent paid attn to all the name changes. Not hassio. Regualer home assistant in docker. config is at /home/homeassistant/.homeassistant

Ive whitelisted the path and also tried with /config

when you call a script with a path how do you use the ./

Ive only used ./filename.sh from within the dir

I’d try something like:

/home/homeassistant/.homeassistant/cast.sh

The ./ you’re talking about just means look for this in Ethernet directory you’re already in, but that won’t work from HA.

I’d also try to drop the shell script and call the catt command directly. But again, you’ll need full path to catt. Try “which catt” to find.

I think your on to some thing. What do you mean by just the shell script? Just call each command without the script file? Catt is located in /usr/local/bin/catt

In the logs I see it failed with error 127…google tells me that means it doesnt know that command…so i believe your right.

How would I call that using the path Catt is in? (this is one thing I really need to learn, the PATH$ always confuses me)

/usr/local/bin/catt -d ‘Bathroom Display’ cast_site http://10.1.99.111:8123/lovelace/home

I still get 127.

I whitelisted /usr/local/bin too. But since its docker isnt /usr/local/bin within that container, the container doesnt know about the hosts /usr unless its mapped…I guess i can try installing catt within the container…thanks for helpin man

Right. Anything command line is much more complicated with Docker.

I got it…def a hack but hey:) installed catt on another box, created an ssh key and put it in my config dir and then use this shell command

ssh -i ssh/id_rsa -o StrictHostKeyChecking=no [email protected] "/usr/local/bin/catt -d 'Baseme
nt display' cast_site 'http://10.1.99.111:8123/lovelace/arbos-home'"
1 Like