[newbie] How to make a node-red flow for this bash-command

I'm trying to make the following command work in node-red:
/usr/bin/mpg321 http://progressive-audio.lwc.vrtcdn.be/content/fixed/11_11niws-snip_lo.mp3

It doesn't seem a matter of just putting the command in an exec-node...
How should I proceed?

kind regards,
Hugo

Normally it should be just that simple but you did mention in another post that your running node-red in a docker container, am i right or am i confusing things?
If this is the case i’m not sure if Nodered has excess to mpg321 if it’s installed outside of the container.
But to narrow it down connect a debug node to all 3 outputs of the exec node and show us the outputs you get when you try to run the command.

Hey Hugo!

Do you want to "run" it in dashboard? If yes:
You could make an UI-template, you just need to press "play".

<audio controls>
  <source src="http://progressive-audio.lwc.vrtcdn.be/content/fixed/11_11niws-snip_lo.mp3" type="audio/mpeg">
</audio>

Looks like:
image

Flow:

[{"id":"22ac405d.d244c","type":"ui_template","z":"24d31ef4.bdf632","group":"51404579.1d62dc","name":"","order":3,"width":0,"height":0,"format":"<audio controls>\n  <source src=\"http://progressive-audio.lwc.vrtcdn.be/content/fixed/11_11niws-snip_lo.mp3\" type=\"audio/mpeg\">\n</audio>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":1950,"y":2020,"wires":[[]]},{"id":"51404579.1d62dc","type":"ui_group","z":"","name":"Persoonsgegevens","tab":"42c0724c.82676c","order":1,"disp":true,"width":"6","collapse":false},{"id":"42c0724c.82676c","type":"ui_tab","z":"","name":"Aanmelden","icon":"group","order":1,"disabled":false,"hidden":false}]

Arne

1 Like

Check all three outputs from the exec node to see if there are any clues about what is going on. Also make sure that you do not have Append Payload set in the exec node (unless you want it).

Normally it should be just that simple but you did mention in another post that your running node-red in a docker container, am i right or am i confusing things?
If this is the case i’m not sure if Nodered has excess to mpg321 if it’s installed outside of the container.
But to narrow it down connect a debug node to all 3 outputs of the exec node and show us the outputs you get when you try to run the command.

This is the output you asked for:

code: 127

message: "Command failed: /usr/bin/mpg321 http://progressive-audio.lwc.vrtcdn.be/content/fixed/11_11niws-snip_lo.mp3↵/bin/bash: /usr/bin/mpg321: No such file or directory↵"

Probably again something which has to do with the docker containers?
The strange thing is that Node-RED as such is able to play the stream as suggested by ArneR (who withdraw his answer a few seconds after I imported his flow...)
You can see this in this flow:

[{"id":"b5c9031e.3f6cd","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"3892de81.b1aeaa","type":"ui_template","z":"b5c9031e.3f6cd","group":"ca08eeb9.434f68","name":"Jongste Nieuws","order":1,"width":0,"height":0,"format":"<audio controls>\n <source src=\"http://progressive-audio.lwc.vrtcdn.be/content/fixed/11_11niws-snip_lo.mp3\" type=\"audio/mpeg\">\n</audio>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":700,"y":320,"wires":[[]]},{"id":"f8843bb4.5455d8","type":"exec","z":"b5c9031e.3f6cd","command":"/usr/bin/mpg321 http://progressive-audio.lwc.vrtcdn.be/content/fixed/11_11niws-snip_lo.mp3","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":560,"y":200,"wires":[["ab817b9e.05b938"],["ab817b9e.05b938"],["ab817b9e.05b938"]]},{"id":"82de2858.ddeec8","type":"inject","z":"b5c9031e.3f6cd","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":220,"wires":[["f8843bb4.5455d8"]]},{"id":"ab817b9e.05b938","type":"debug","z":"b5c9031e.3f6cd","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1040,"y":180,"wires":[]},{"id":"ca08eeb9.434f68","type":"ui_group","z":"","name":"Group 1","tab":"407e1078.7c1238","order":1,"disp":true,"width":"6","collapse":false},{"id":"407e1078.7c1238","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":7,"disabled":false,"hidden":false}]

kind regards,
hugo

As suggested, I believe you cannot access /usr/bin outside the docker container, so unless you have installed that application inside the container then I think it will not work.

2 Likes

Yes this is because what @ArneR suggested is not happening on the machine Nodered is running on but instead on the machine that you access the dashboard from as that way is purely a front end thing where you are utilizing the playback capabilities of your browser to directly play the stream without ever actually using the machine nodered runs on.

Yes looks like I suggested. You would have to install mpg321 inside the container as this is exactly what docker does, it gives you an isolated standalone container to run things that can be very limiting in the ways that you can interact with the host system.

1 Like