<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[exec error: Error: Command failed: ?!]]></title><description><![CDATA[<p dir="auto">hallo @ all ,</p>
<p dir="auto">i am new here and german, so sorry for my english  :-)</p>
<p dir="auto">i build my first module. i started with <a href="https://forum.magicmirror.builders/topic/4667/solved-socket-notification-not-working?_=1625397975105">this</a> simple module.</p>
<p dir="auto">it works. then i add an exec command</p>
<pre><code>exec("bash ../MagicMirror/config/test.sh", (error, stdout, stderr) =&gt; {
	if (error) {
		console.error(`exec error: ${error}`)
		return;
	}
</code></pre>
<p dir="auto">thats works ?! i am not sure.<br />
the <a href="http://test.sh" target="_blank" rel="noopener noreferrer nofollow ugc">test.sh</a></p>
<pre><code>cp ../MagicMirror/config/config.js ../MagicMirror/config/config_1.js
pm2 restart all
</code></pre>
<p dir="auto">in my custom_menu.json i have an entry that send the notification  <strong>TEST</strong>,  my MMM_MeinModul.js recieved this and send</p>
<pre><code>this.sendSocketNotification('START_TEST', {});
</code></pre>
<p dir="auto">when my node_helper.js recieved this then call the function with the exec command.</p>
<p dir="auto">the result is an error at pm2 log:</p>
<pre><code>exec error: Error: Command failed: bash ../MagicMirror/config/test.sh
</code></pre>
<p dir="auto">but thats not true. the <em>pm2 restart all</em> are executed and restart the mm.</p>
<pre><code>playerRadio
0|MagicMirror  | [06.07.2021 19:22.56.851] [LOG]   Stopping module helper: MMM-Tools
0|MagicMirror  | [06.07.2021 19:22.56.883] [ERROR] 
0|MagicMirror  | exec error: Error: Command failed: bash ../MagicMirror/config/test.sh
0|MagicMirror  | &gt; magicmirror@2.16.0 start /home/pi/MagicMirror
0|MagicMirror  | &gt; DISPLAY="${DISPLAY:=:0}" ./node_modules/.bin/electron js/electron.js
0|MagicMirror  | [06.07.2021 19:23.02.329] [LOG]   
0|MagicMirror  | Starting MagicMirror: v2.16.0

</code></pre>
<p dir="auto">so, i think the cp command not work, but i dont understand the problem.</p>
<p dir="auto">here my module</p>
<pre><code>Module.register("MMM-MeinModul",{
	defaults: {
		text: "Sergio"
	},

	getDom: function() {
		var wrapper = document.createElement("div");
		wrapper.innerHTML = this.config.text;
		return wrapper;
	},

	start: function() {
		this.sendSocketNotification('CONFIG', this.config);
	},

	socketNotificationReceived: function(notification, payload) {
		if (notification === 'STARTED') {
			console.log("MMM-MeinModule notification [" + notification + "] payload [" + payload + "]")
			this.config.text = 'Started';
			this.updateDom();
		}
	},
	
	notificationReceived: function(notification, payload) {
		if (notification === 'TEST') {
			console.log("MMM-MeinModule notification [" + notification + "] payload [" + payload + "]")
			this.config.text = 'changed';
			this.updateDom();
			this.sendSocketNotification('START_TEST', {});
		}
	}
});
</code></pre>
<p dir="auto">and here my node_helper</p>
<pre><code>var NodeHelper = require("node_helper");
const exec = require("child_process").exec;

module.exports = NodeHelper.create({
	start: function () {
		this.config = {}
	},
	
copyfile: function () {
console.log(__dirname)
exec("bash ../MagicMirror/config/test.sh", (error, stdout, stderr) =&gt; {
	if (error) {
		console.error(`exec error: ${error}`)
		return;
	}
});
},

	socketNotificationReceived: function (notification, payload) {
		if (notification === 'CONFIG') {
			this.config = payload;
			console.log("MMM-MeinModule node_helper (config) notification [" + notification + "] payload [" + payload + "]")
			this.sendSocketNotification('STARTED',payload);
		}
		if (notification === 'START_TEST') {
			console.log("MMM-MeinModule node_helper (TEST) notification [" + notification + "] payload [" + payload + "]")
			this.copyfile();
		}
	}
});
</code></pre>
<p dir="auto">can sameone get a hint please ?</p>
]]></description><link>https://forum.magicmirror.builders/topic/15233/exec-error-error-command-failed</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Apr 2026 12:29:05 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/15233.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Jul 2021 18:12:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Thu, 08 Jul 2021 18:19:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">i have test a lot with file attributes. not needed.  magicMirror is not linux, its javascript. only the copy command and pm2 command in the exec function must linux conform. in the pm2 log you have sometimes error messages, but that comes from linux. so you have right, without x-flag its not executable, but MagicMirror ignore file attributes.</p>
<p dir="auto">now i can cange all my configs with remote-control. for the moment i am finished this module. maybe later i have a new idea, ha,ha.</p>
]]></description><link>https://forum.magicmirror.builders/post/92638</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92638</guid><dc:creator><![CDATA[stoffel]]></dc:creator><pubDate>Thu, 08 Jul 2021 18:19:12 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Wed, 07 Jul 2021 19:46:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/stoffel" aria-label="Profile: stoffel">@<bdi>stoffel</bdi></a>  I do this in MMM-Config, node_helper</p>
<pre><code>  exec("pm2 restart " + pm2_id);
</code></pre>
<p dir="auto">after I get the id from pm2 info and find the entry that matches the path we are running under</p>
]]></description><link>https://forum.magicmirror.builders/post/92621</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92621</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Wed, 07 Jul 2021 19:46:27 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Wed, 07 Jul 2021 18:49:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">ok, what can i say. i’v test it with other config und it works also. its overide the old config with the new config and restart mm.<br />
i not understand why, but it works. realy</p>
]]></description><link>https://forum.magicmirror.builders/post/92620</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92620</guid><dc:creator><![CDATA[stoffel]]></dc:creator><pubDate>Wed, 07 Jul 2021 18:49:00 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Wed, 07 Jul 2021 18:16:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/stoffel" aria-label="Profile: stoffel">@<bdi>stoffel</bdi></a> not needed… exec should fail if the execute bit is not on…(it would be a security exposure to allow ‘anything’ to execute)   but not my job</p>
]]></description><link>https://forum.magicmirror.builders/post/92619</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92619</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Wed, 07 Jul 2021 18:16:19 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Wed, 07 Jul 2021 18:14:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">ok, i am not a linux erpert. i think the exec command execute a script, and its work with this file-attributes. you can test it. maybe its read the file and exec the commands in it. i’v checked the attributes with filezilla, was 644, not executable but it works.</p>
<p dir="auto">the file-attributes are for the security of RPI &amp; MM importend. thats is for later.</p>
<p dir="auto">at the moment ist works without errors. i can send you my files for test !?</p>
]]></description><link>https://forum.magicmirror.builders/post/92618</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92618</guid><dc:creator><![CDATA[stoffel]]></dc:creator><pubDate>Wed, 07 Jul 2021 18:14:42 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Wed, 07 Jul 2021 17:56:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/stoffel" aria-label="Profile: stoffel">@<bdi>stoffel</bdi></a> said in <a href="/post/92615">exec error: Error: Command failed: ?!</a>:</p>
<blockquote>
<p dir="auto">its a simple text-file</p>
</blockquote>
<p dir="auto">unix is cool… ANYTHING can be executable… and a ‘script’ is just a text file with the executable flag on<br />
the .sh means nothing (just convention to say shell script)</p>
<p dir="auto">I dson’t use .sh in most of my scripts, cause its just another thing the user has to type and doesn’t help</p>
<p dir="auto">also, in unix, if the 1st line of the executable text file</p>
<p dir="auto">starts with shebang #!<br />
then the program to execute this  ‘script’ is specified next</p>
<pre><code>#!/bin/bash 
</code></pre>
<p dir="auto">means bash will execute this program, so bash (/bin/bash) is launched and passed this script</p>
]]></description><link>https://forum.magicmirror.builders/post/92617</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92617</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Wed, 07 Jul 2021 17:56:26 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Wed, 07 Jul 2021 17:52:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/stoffel" aria-label="Profile: stoffel">@<bdi>stoffel</bdi></a> said in <a href="/post/92615">exec error: Error: Command failed: ?!</a>:</p>
<blockquote>
<p dir="auto">and its executable -rw-r–r–</p>
</blockquote>
<p dir="auto">is NOT executable</p>
<p dir="auto">it needs the x flag</p>
<p dir="auto">now its executable xrwxr–xr–</p>
<p dir="auto">there are 3 bits each</p>
<p dir="auto">for the user themselves<br />
for others in the same group as the user<br />
and for ‘others’</p>
<p dir="auto">sometimes shortened to UGA</p>
<p dir="auto">u can set the flags with<br />
chmod   the numbers 7 is all bits  (777)<br />
or just for the user  766<br />
or read only for anyone except the user  744</p>
<p dir="auto">to turn on the execute flag for any and all its +x<br />
(to turn it off is -x)<br />
r and w are read and write</p>
]]></description><link>https://forum.magicmirror.builders/post/92616</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92616</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Wed, 07 Jul 2021 17:52:44 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Wed, 07 Jul 2021 17:48:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">look at my first post, its a simple text-file with the extension .sh and its executable -rw-r–r–<br />
the <a href="http://test.sh" target="_blank" rel="noopener noreferrer nofollow ugc">test.sh</a> is not the problem, the file ist found and execute it. the problem was the cp command. but now i soved the problem.</p>
<pre><code>cp -a -v ../MagicMirror/config/config.js ../MagicMirror/config/config_1.js 1&gt;&gt; ./log_erfolgreich.txt 2&gt;&gt; ./log_fehlgeschlagen.txt
pm2 restart all
</code></pre>
<p dir="auto">i add the option -a . now its work !!<br />
the <em>log_erfolgreich.txt</em> and <em>log_fehlgeschlagen.txt</em> are found in the MagicMirror dir, so cp starts at this dir.<br />
the</p>
<pre><code>../MagicMirror/
</code></pre>
<p dir="auto">are needed, maybe mm starts from the .pm2 dir?!</p>
<p dir="auto">i play around with it and other files (txt, png…)<br />
i am lucky :-)<br />
<strong>thanks very much for your help.</strong></p>
<p dir="auto">at WE i test your config-module and post it</p>
]]></description><link>https://forum.magicmirror.builders/post/92615</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92615</guid><dc:creator><![CDATA[stoffel]]></dc:creator><pubDate>Wed, 07 Jul 2021 17:48:12 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Wed, 07 Jul 2021 16:53:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/stoffel" aria-label="Profile: stoffel">@<bdi>stoffel</bdi></a> us the file marked excecutable?</p>
<p dir="auto">ls -laF ../MagicMirror/config/test.sh</p>
<p dir="auto">if the file starts with the shebang, then u don’t need to use bash either</p>
<pre><code>#!/bin/bash
rest of script
</code></pre>
<p dir="auto">chmod +x  ../MagicMirror/config/test.sh</p>
<p dir="auto">it is really in the config folder?</p>
]]></description><link>https://forum.magicmirror.builders/post/92614</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92614</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Wed, 07 Jul 2021 16:53:40 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Wed, 07 Jul 2021 16:49:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">i’v test the exec command without bash… thats not work, i have a<br />
<em>/bin/sh: 1: …/MagicMirror/config/test.sh: Permission denied</em></p>
<p dir="auto">with bash it works now, but the filename is a bit crazy<br />
<img src="/assets/uploads/files/1625670722126-cp-config.png" alt="cp config.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">thats at ssh console. in filezilla the filename is correct but says <em>no such file or directory</em></p>
<p dir="auto">i have no idea what gos wrong</p>
]]></description><link>https://forum.magicmirror.builders/post/92613</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92613</guid><dc:creator><![CDATA[stoffel]]></dc:creator><pubDate>Wed, 07 Jul 2021 16:49:04 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Tue, 06 Jul 2021 19:39:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">fine, i will test it at WE.<br />
Now its time to sleep. i test tomorrow with sh … and without bash/sh</p>
]]></description><link>https://forum.magicmirror.builders/post/92589</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92589</guid><dc:creator><![CDATA[stoffel]]></dc:creator><pubDate>Tue, 06 Jul 2021 19:39:12 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Tue, 06 Jul 2021 19:35:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/stoffel" aria-label="Profile: stoffel">@<bdi>stoffel</bdi></a> yes, my config module is pretty good…<br />
waiting for more error reports from users …</p>
<p dir="auto">because you are launching the program (bash) … the console comes to your program not to the log…</p>
<p dir="auto">in my uploadPics module I just console.log() whatever comes back from my shell pgm…<br />
then it shows in the MM log</p>
]]></description><link>https://forum.magicmirror.builders/post/92588</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92588</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 06 Jul 2021 19:35:04 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Tue, 06 Jul 2021 19:06:52 GMT]]></title><description><![CDATA[<p dir="auto">hallo sdetweil,</p>
<p dir="auto">have you finished your config-module :face_with_steam_from_nose: ?</p>
<p dir="auto">the __dirname was from the beginning when i have a <em>file not found</em> error. now its found and i think  the exec comand works, in log you can see after the error restart mm but i have no error message from then cp command. so i can not find whats the problem is. in the console.log i have no errors. where can i see error messages from the cp command.</p>
]]></description><link>https://forum.magicmirror.builders/post/92587</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92587</guid><dc:creator><![CDATA[stoffel]]></dc:creator><pubDate>Tue, 06 Jul 2021 19:06:52 GMT</pubDate></item><item><title><![CDATA[Reply to exec error: Error: Command failed: ?! on Tue, 06 Jul 2021 18:31:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/stoffel" aria-label="Profile: stoffel">@<bdi>stoffel</bdi></a> make sure to change to the right folder …</p>
<p dir="auto">console.log(__dirname)  is where the source file is located, NOT the current folder</p>
<p dir="auto">when modules are executed, the current folder is where the caller is…</p>
<p dir="auto">pm2 doesn’t launch MM from within the MM folder…</p>
<p dir="auto">best to use the full path</p>
<p dir="auto">this.path is the full path to the module folder</p>
]]></description><link>https://forum.magicmirror.builders/post/92586</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/92586</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 06 Jul 2021 18:31:38 GMT</pubDate></item></channel></rss>