# Exec node can't execute the command but terminal does

**URL:** https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892
**Category:** General
**Created:** [6 April 2022 18:57 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892 "2022-04-06T18:57:56Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Raver](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Raver](https://discourse.nodered.org/u/Raver)
#### Post date: [6 April 2022 18:57 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/1 "2022-04-06T18:57:56Z")

</div>

Hi.  
I can run in terminal: "./speech.sh hello" all ok but in exec node runs with no error, i didn't hear "hello" from speakers and the output message is: Terminal type `unknown' is not defined.  
Can anyone help me i tried everything.  
Is it possible to run this command from node-red?

---

<div class="post-metadata">

### Author: ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)
#### Post date: [6 April 2022 19:17 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/2 "2022-04-06T19:17:38Z")

</div>

Where is the `speech.sh` file? and What **exactly** did you put into the exec node?

Also what is the first line of the script?

---

<div class="post-metadata">

### Author: ![Raver](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Raver](https://discourse.nodered.org/u/Raver)
#### Post date: [6 April 2022 19:36 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/3 "2022-04-06T19:36:11Z")

</div>

the file

```auto
#!/bin/bash
say() { local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols "http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=$*&tl=en"; }
say $*

```

The file is in the home folder and i try to execute the command with whole path of the file from exec same result  
Exec node edit: command: ./speech and the payload is: hello  
I use google tts language (text to speech)  
RPi 4 raspbian

---

<div class="post-metadata">

### Author: ![Raver](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Raver](https://discourse.nodered.org/u/Raver)
#### Post date: [6 April 2022 20:05 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/5 "2022-04-06T20:05:17Z")

</div>

the flow

```auto
[{"id":"ba75182c1bcff601","type":"exec","z":"f10a1076.cc20b","command":" ./speech.sh","addpay":"payload","append":"","useSpawn":"false","timer":"20","winHide":false,"oldrc":false,"name":"","x":760,"y":1020,"wires":[["02e1579a7bcba2fa"],[],[]]},{"id":"b8b3791d832ef9cf","type":"inject","z":"f10a1076.cc20b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello","payloadType":"str","x":560,"y":1040,"wires":[["ba75182c1bcff601"]]}]

```

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [6 April 2022 20:13 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/6 "2022-04-06T20:13:15Z")

</div>

The exec node doesn't know where " ./speech.sh" is. you need to put the full path to  
speech.sh in the node.

---

<div class="post-metadata">

### Author: ![Raver](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Raver](https://discourse.nodered.org/u/Raver)
#### Post date: [6 April 2022 20:25 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/7 "2022-04-06T20:25:46Z")

</div>

I try it with full path same result

```auto
[{"id":"ba75182c1bcff601","type":"exec","z":"f10a1076.cc20b","command":" /home/pi/speech.sh ","addpay":"payload","append":"","useSpawn":"false","timer":"20","winHide":false,"oldrc":false,"name":"","x":780,"y":1020,"wires":[["02e1579a7bcba2fa"],[],[]]},{"id":"b8b3791d832ef9cf","type":"inject","z":"f10a1076.cc20b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"hello","payloadType":"str","x":560,"y":1040,"wires":[["ba75182c1bcff601"]]}]

```

i also copy the file in node-red folder

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [6 April 2022 20:55 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/8 "2022-04-06T20:55:09Z")

</div>

When you are in the folder where the command line command "./speech.sh hello" works for you, what does the command "pwd" show?

---

<div class="post-metadata">

### Author: ![Raver](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Raver](https://discourse.nodered.org/u/Raver)
#### Post date: [6 April 2022 21:03 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/9 "2022-04-06T21:03:36Z")

</div>

> [@ghayne](#):
>
> pwd

```auto
pi@raspberrypi:~ $ pwd
/home/pi
pi@raspberrypi:~ $ cd /home/pi/.node-red/
pi@raspberrypi:~/.node-red $ pwd
/home/pi/.node-red 
pi@raspberrypi:~/.node-red $ ls
flows_raspberrypi_cred.json lib package-lock.json speech.sh
flows_raspberrypi.json node_modules settings.js
hourglass package.json sonospollyttsstorage

```

---

<div class="post-metadata">

### Author: ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)
#### Post date: [6 April 2022 21:40 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/10 "2022-04-06T21:40:21Z")

</div>

So the command should be `/home/pi/.node-red/speech.sh` not `/home/pi/speech.sh`

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [7 April 2022 07:05 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/11 "2022-04-07T07:05:24Z")

</div>

It might not be a file path problem but make sure you've tested that all out 1st

When running audio stuff from the exec node - you sometimes have to be explict about specifying what audio hardware to use.

I play an mp3 via an exec node and had to add in lots of stuff to get it work

```auto
mpg123 -a plughw:1,0 alexa.mp3

```

You might have to do something similar to hear your speech

It took a lot of googling to find out how to get mine to work

---

<div class="post-metadata">

### Author: ![Raver](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Raver](https://discourse.nodered.org/u/Raver)
#### Post date: [7 April 2022 08:09 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/12 "2022-04-07T08:09:14Z")

</div>

I try with `/home/pi/.node-red/speech.sh` and gives error.  
I think Cymplecy is right i must put something in the command about the audio.  
I was googling but i didn't find somethin similar.

---

<div class="post-metadata">

### Author: ![Raver](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Raver](https://discourse.nodered.org/u/Raver)
#### Post date: [7 April 2022 12:54 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/13 "2022-04-07T12:54:45Z")

</div>

Is an other way to execute this command via node-red?  
Or an other way to make my RPi speak in foreign language for example Greek via node-red text-to-speech?  
To complete my project i need only this and i will be pleased if someone find me a solution.  
Thanks

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [6 June 2022 12:55 UTC](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/14 "2022-06-06T12:55:36Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
