Shell command error 126

Hello everybody!

I’m trying to get this script working from Home assistant node-red without success:
The script works when manually executed frome command line.
the file has been chmod +x.
I have other scripts called the exact same way and i do no understant why this one dont.

ssh -i "/config/scripts/id_rsa" -o StrictHostKeyChecking=no pi@hostname "sudo bash /home/pi/"

Configuration.yaml looks like:

  audio_shutdown: 'bash -c /config/scripts/'
  playlist_exporter: 'bash -c /config/scripts/'
  homeassistant_backup: 'bash -c /config/scripts/'

Error code in HA looks like this:

## Log Details (ERROR)

Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/
Integration: shell_command ([documentation](, [issues](
First occurred: 12:14:57 PM (1 occurrences)
Last logged: 12:14:57 PM

Error running command: `bash -c /config/scripts/`, return code: 126

NoneType: None

The called script looks like this:


#installation if needed

if  [[ $1 = "-i" ]]; then
	echo "installing"
	sudo apt-get install -y sshpass rename
	if [ ! -d "/home/pi/imported_playlists" ]; then
	mkdir "/home/pi/imported_playlists"

#----- Importation des playlists --------------------------------------------------------
    echo "suppression des anciennes playlists"
	rm -f /home/pi/imported_playlists/*
	rm -f /var/lib/mpd/playlists/*
	echo "importation des playlists"
	sudo sshpass -p "password" sftp -o StrictHostKeyChecking=no "root@hostname:/sharedfolders/share/musique/playlists/* /home/pi/imported_playlists/"
	echo "changement de repertoire"
	cd /home/pi/imported_playlists/
	echo "renommage et conversion:"
	rename -f 's/.m3u8/.m3u/' *.m3u8
	echo "Modification du chemin dans les playlists"
	sed -i 's#/airsonic#NAS#g; s#music#Musique#g' *.m3u
	echo "playlists renommées - copie dans le dossier d'exploitation"
	cp -f /home/pi/imported_playlists/* /var/lib/mpd/playlists/
	chmod -R 777 /var/lib/mpd/playlists/
	chown mpd:audio /var/lib/mpd/playlists/*
	echo "Mise a jour de la bibliotheque"
	sleep 5
	mpc update

Any hint appreciated !

Regards - JS

I would start with small steps. What I mean by that is to see first of all, for example, the first part of the script.

So you leave the below part of the script in the file and try to run it. If it works, than add some more code and see again. This way will be able to spot the issue.


#installation if needed

if  [[ $1 = "-i" ]]; then
	echo "installing"
	sudo apt-get install -y sshpass rename
	if [ ! -d "/home/pi/imported_playlists" ]; then
	mkdir "/home/pi/imported_playlists"

EDIT: Just tried again, everything is working now - no changes made :-/

Thanks! xD