Problem with Exec

Hi, I'm using the exec node in Node-RED. I want to play a sound clip when I give input to the exec node. When I run the command manually via the command line in Putty, everything works fine. However, when I run the same command in the exec node, nothing happens. There are no error messages, and in debug 3, it shows 'code 0'.

What could be wrong?

This is tricky.

I've checked on one of my machines and it can be done.

Could you open the exec node and screenshot what you have there?

Ok, pretty much the same as I have.

So you connect to the remote machine via Putty and you enter mpg123 /home/louis/Music/hoho1.mp3 and you hear the sound?

Sorry, I just want to be sure.

I think there is a problem with the path.

You need to enable your public thing in the settings file for node-red

so the sound file has to be in that directory.

eg: from my working one.
(This is in a template node to build the message)
/home/pi/.node-red/public/Sounds/{{payload}}
and my exec node uses the payload

(settings file change needed)

    // When httpAdminRoot is used to move the UI to a different root path, the
    // following property can be used to identify a directory of static content
    // that should be served at http://localhost:1880/.
    //httpStatic: '/home/nol/node-red-static/',
    httpStatic: '/home/pi/.node-red/public',     //  <-- this line here
    //httpStatic: '/home/pi',

Hope that helps.

Yes I do it and it works in Putty

See my last post.

I really suspect that is the problem.

Something to do with permissions.

The file to be played has to be in the declared public directory - as set in the settings.js file in the .node-red directory.

So you will have to make a directory in .node-red called public (or Public if you want) then you put the sound file in that directory.

OR you add a sub-directory for sounds, and put the file in that one.

Sorry I can't be more helpful, it is near my limits of help.
So the command would be more like:
mpg123 /home/pi/louis/.node-red/public/sound/hoho1.mp3

AND you will have to restart node-red to get it working.


It does it in Putty but not in Node-red.
The difference is that I don't have the pi folder I think.

Sorry, my mistake.

Where I have pi you will have louis.

Try that.

Don't forget to edit the settings.js file too and restart `node-red``.

I don't understand what to do with the settings.js

You need to edit it.

Find the line with httpStatic in it and set the path - as shown, but change pi to louis

Then make the directory public in the .node-red directory.

I work directly with a mouse and keyboard on the Raspberry Pi. I see the settings.js file located in the /home/louis/.nodered folder.

Please set the debug nodes to Output Complete Message and show us the output for each of them.

I'm confused.

I work directly with a mouse and keyboard on the Raspberry Pi.

So why do you need to use putty to get to it?

First off:

mkdir public

Then edit the settings.js file.
eg:
nano settings.js
Then scroll down and find the line httpStatic
Change the line and save.
then put a copy of the file you want to play in that directory.

Ok, but you will need to remove the two leading // as they make the line a comment.

And have another look at the path.

Then look at what I posted.

There IS a difference - beyond the pi/louis part.

Ok, looking at the other lines, I may be wrong.

THIS IS NOW BEYOND MY KNOWLEDGE BASE.

Just to be sure

THIS IS NOW BEYOND MY KNOWLEDGE BASE.

Sorry.

I am making a kind of Steady Hand Game with a Siemens Logo. When the spiral is touched, a buzzer sounds, which is controlled by the Logo. At the end of the game, the ring makes contact with a separate input on the Logo.

After that, a hoho.mp3 sound clip should play.
I already tried this with the 'Audio Out' in Node-RED, but it played through my PC speakers instead of the Raspberry Pi.
I’m almost at my wit’s end, and I’m not very experienced with programming in Putty yet.