Help needed for hassio.stdin

I am trying to use hassio.stdin but I can’t make it work.

So what I did: I created a shell script located in “/config” called “myscript.sh”.

I would like to run that script in a ssh shell using hassio.stdin.

So I wrote the service like this (a0d7b954-ssh is my hostname for “SSH and Terminal” add-on):

service: hassio.addon_stdin
data:
  addon: a0d7b954-ssh
  input: "/config/myscript"

But nothing happens in SSH & Terminal log…

Maybe it is misconfigured or a misunderstanding on my side…

Any help will be appreciated.

If your script is really called myscript.sh, then you need to call it as such, and you need to use a proper slug for the addon:

service: hassio.addon_stdin
data:
  addon: a0d7b954_ssh
  input: "/config/myscript.sh"

1 Like

Thanks, I got it to work !!! I tried so many different ways including uninstalling/installing SSH add-on… but finally it works !

service: hassio.addon_stdin
data:
  addon: a0d7b954_ssh
  input: "/bin/bash /config/myscript.sh"
3 Likes

@browetd

i have exactly the same problem! thanks a lot!

i put the same command that work in the terminal but doesnt work with the script (try with and without sudo) :

sudo docker container exec -it homeassistant /bin/bash
sudo mount /dev/sdb1 /media/usbstorage

what did you put in you script.sh please?

Can you help a little bit please?

Here is what I did (I am starting to lauch a _ini shell to be able to get the output of the command shell…

In automations, I put the following action:

    - service: hassio.addon_stdin
      data:
        addon: a0d7b954_ssh
        input: "/bin/bash /config/heatpump_off_ini.sh"

Than I have the ini shell (heatpump_off_ini.sh):

#!/bin/bash
#
#

/config/heatpump_off.sh &> /config/heatpump_off_ini.log &

and then my “command” shell (this is just to show that I am putting “/bin/bash” everywhere !):

#!/bin/bash

/config/heatpump.sh off
/config/heatpump.sh info

Hoping this will work for you…

1 Like

thanks for your help,

i have found exactly what i need : https://community.home-assistant.io/t/add-on-hassos-ssh-port-22222-configurator/264109 + samba nas addon, just use this last one for auto mount disk at boot :wink: : https://community.home-assistant.io/t/new-addon-samba-nas-mount-external-disk-and-share-it/172193/204

2 Likes

I’m sorry for reviving this but it’s exactly my problem.

I’m trying to run

action: hassio.addon_stdin
data:
  addon: a0d7b954_ssh
  input: "/bin/bash /config/immich_db_backup.sh"

Running /config/immich_db_backup.sh from within the SSH addon works perfect.

But running the action, nothing happens. Nothing in the logs either.

When it was working, did you see anything in the logs or anywhere?

Thanks!

The service “hassio.addon_stdin” has been removed a (very) long time ago… I am using now shell commands… Examples, the first one is obvious, you submit a shell scripts in the HA container with the results written in a logfile, the second one is used when there is unknown commands in the HA container (like “mount”) but the procedure is running well in the terminal window:

shell_command:
  delete_files: /bin/bash /config/private_shell_scripts/delete_files.sh > /config/private_logfiles/delete_files.log
  rsync_mynas: ssh root@<your HA ip address> -o 'StrictHostKeyChecking=no' -i /config/.ssh/id_rsa '/bin/bash /config/private_shell_scripts/rsync_mynas_ini.sh >&/config/private_logfiles/rsync_mynas_ini.log 2>&1'

I hope this is helping… and sorry for the delay answering your question.

1 Like

Hi,

I have HAOS a problem sending a shell_command.

  spusti_vypln_pdf: ssh root@localhost -o 'StrictHostKeyChecking=no' -i /config/.ssh/id_rsa '/bin/bash /config/scripts/spusti_vypln_pdf.sh >&/config/spusti_vypln_pdf.log 2>&1'

I keep getting:

stdout: ""
stderr: "Permission denied, please try again.\r\nPermission denied, please try again.\r\nroot@localhost: Permission denied (publickey,password)."
returncode: 255

The script works for me manually in Advanced SSH. Any advice?

Are you using “Advanced SSH & Web Terminal” as add-on ?