<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=4266&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / [SOLVED] Help with script]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=4266</link>
		<description><![CDATA[The most recent posts in [SOLVED] Help with script.]]></description>
		<lastBuildDate>Wed, 14 Apr 2021 19:25:36 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: [SOLVED] Help with script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29117#p29117</link>
			<description><![CDATA[<p>Hello:</p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>... you must have missed them when you copied it.</p></div></blockquote></div><p>Painted short, probably?<br />Have to be more careful.</p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>... script used bash but didn&#039;t contain anything that actually needed bash.</p></div></blockquote></div><p>I see.</p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>... prefer /bin/sh over /bin/bash because it&#039;s faster, lighter and less buggy.<br />The Debian developers also prefer /bin/sh for the same reasons and went to quite some effort replacing all of the bash system scripts with /bin/sh versions.</p></div></blockquote></div><p>Kudos to them.<br />Thanks for taking the time to explain.</p><p>Best,</p><p>A.</p>]]></description>
			<author><![CDATA[dummy@example.com (Altoid)]]></author>
			<pubDate>Wed, 14 Apr 2021 19:25:36 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29117#p29117</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Help with script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29116#p29116</link>
			<description><![CDATA[<div class="quotebox"><cite>Altoid wrote:</cite><blockquote><div><p>Never thought it would have a problem.</p></div></blockquote></div><p>The script on GitHub does actually have the backticks, you must have missed them when you copied it.</p><div class="quotebox"><cite>Altoid wrote:</cite><blockquote><div><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>POSIX sh ftw!</p></div></blockquote></div><p>Don&#039;t quite follow you</p></div></blockquote></div><p>The original script used bash but didn&#039;t contain anything that actually needed bash. The tests (<span class="bbc">[[...]]</span>) were the bash version but the /bin/sh (<a href="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html#top" rel="nofollow">POSIX</a>) test (<span class="bbc">[...]</span>) works just as well. I always prefer /bin/sh over /bin/bash because it&#039;s faster, lighter and less buggy. The Debian developers also prefer /bin/sh for the same reasons and went to quite some effort replacing all of the bash system scripts with /bin/sh versions. Ubuntu also did this: <a href="https://wiki.ubuntu.com/DashAsBinSh" rel="nofollow">https://wiki.ubuntu.com/DashAsBinSh</a></p>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Wed, 14 Apr 2021 19:12:13 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29116#p29116</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Help with script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29113#p29113</link>
			<description><![CDATA[<p>Hello:</p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>Use <a href="https://www.shellcheck.net/" rel="nofollow">https://www.shellcheck.net/</a> to test scripts.</p></div></blockquote></div><p>Thanks for the heads up.<br />Will bookmark that one for the next time.</p><p>Being a script from github, I assumed an error of some sort at my end. <br />As it seemed harmess enough, I just copied it, made it executable and tried it.<br />Never thought it would have a problem.</p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>Better version:</p><div class="codebox"><pre><code>#!/bin/sh
 
if [ $# -gt 1 ] || [ &quot;$1&quot; != enable ] &amp;&amp; [ &quot;$1&quot; != disable ]; then
         echo &quot;Usage: $0 &lt;enable|disable&gt;&quot;
         exit 1
fi

if [ &quot;$1&quot; = enable ]; then
        TOGGLE=$(grep &#039;\*disabled&#039; /proc/acpi/wakeup | cut -d &#039; &#039; -f1)

else

        TOGGLE=$(grep &#039;\*enabled&#039; /proc/acpi/wakeup | cut -d &#039; &#039; -f1)

fi

for DEV in $TOGGLE ; do
        echo &quot;$DEV&quot; 
        echo &quot;$DEV&quot; &gt; /proc/acpi/wakeup

done</code></pre></div></div></blockquote></div><p>Right.</p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>POSIX sh ftw!</p></div></blockquote></div><p>Don&#039;t quite follow you, but I&#039;ll take your word for it.&#160; 8^) </p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>... simplified further if all you want to do is disable everything:</p></div></blockquote></div><p>Yes, that would be <em>much</em> better.<br />These <span class="bbc">/proc/acpi/wakeup</span> settings are from <span class="bbc">S4</span>, which my box doesn&#039;t ever/won&#039;t ever go into.<br />And seeing how flaky ACPI tables can be, it&#039;s better to keep this disabled. </p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><div class="codebox"><pre><code>#!/bin/sh

dev=$(awk &#039;/*enabled/{print $1}&#039; /proc/acpi/wakeup)

for i in $dev ; do
   echo &quot;$i&quot; &gt; /proc/acpi/wakeup
done</code></pre></div></div></blockquote></div><p>Works a charm!&#160; 8^D</p><div class="codebox"><pre><code>groucho@devuan:~$ sudo ./acpi_wakeups.sh
[sudo] password for groucho: 
groucho@devuan:~$ </code></pre></div><div class="codebox"><pre><code>groucho@devuan:~$ cat /proc/acpi/wakeup
Device	S-state	  Status   Sysfs node
USB0	  S4	*disabled  pci:0000:00:1d.0
USB1	  S4	*disabled  pci:0000:00:1d.1
USB2	  S4	*disabled  pci:0000:00:1d.2
USB5	  S4	*disabled
EUSB	  S4	*disabled  pci:0000:00:1d.7
USB3	  S4	*disabled  pci:0000:00:1a.0
USB4	  S4	*disabled  pci:0000:00:1a.1
USB6	  S4	*disabled  pci:0000:00:1a.2
USBE	  S4	*disabled  pci:0000:00:1a.7
P0P1	  S4	*disabled  pci:0000:00:01.0
P0P2	  S4	*disabled  pci:0000:00:06.0
P0P3	  S4	*disabled  pci:0000:00:1c.0
BR11	  S4	*disabled
BR12	  S4	*disabled
BR13	  S4	*disabled
P0P4	  S4	*disabled  pci:0000:00:1c.4
BR15	  S4	*disabled
P0P5	  S4	*disabled  pci:0000:00:1e.0
GBE	  S4	*disabled  pci:0000:00:19.0
SLPB	  S4	*disabled
groucho@devuan:~$ </code></pre></div><p>Thank you very much for your input.</p><p>Best,</p><p>A.</p>]]></description>
			<author><![CDATA[dummy@example.com (Altoid)]]></author>
			<pubDate>Wed, 14 Apr 2021 18:47:08 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29113#p29113</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Help with script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29112#p29112</link>
			<description><![CDATA[<p>Hello:</p><div class="quotebox"><cite>chris2be8 wrote:</cite><blockquote><div><p>... use $(...) instead, it&#039;s easier to read if you don&#039;t get muddled about what sort of brackets to use.</p></div></blockquote></div><p>I am not the author of the script.<br />Unfortunately, I don&#039;t have a clue as to how this all works.</p><p>Thanks for your input.</p><p>Best,</p><p>A.</p>]]></description>
			<author><![CDATA[dummy@example.com (Altoid)]]></author>
			<pubDate>Wed, 14 Apr 2021 18:25:09 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29112#p29112</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Help with script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29109#p29109</link>
			<description><![CDATA[<p>Use <a href="https://www.shellcheck.net/" rel="nofollow">https://www.shellcheck.net/</a> to test scripts. That would have identified the problem along with several other issues.</p><p>Better version:</p><div class="codebox"><pre><code>#!/bin/sh
 
if [ $# -gt 1 ] || [ &quot;$1&quot; != enable ] &amp;&amp; [ &quot;$1&quot; != disable ]; then
         echo &quot;Usage: $0 &lt;enable|disable&gt;&quot;
         exit 1
fi

if [ &quot;$1&quot; = enable ]; then
        TOGGLE=$(grep &#039;\*disabled&#039; /proc/acpi/wakeup | cut -d &#039; &#039; -f1)

else

        TOGGLE=$(grep &#039;\*enabled&#039; /proc/acpi/wakeup | cut -d &#039; &#039; -f1)

fi

for DEV in $TOGGLE ; do
        echo &quot;$DEV&quot; 
        echo &quot;$DEV&quot; &gt; /proc/acpi/wakeup

done</code></pre></div><p>POSIX sh ftw!</p><p>It can be simplified further if all you want to do is disable everything:</p><div class="codebox"><pre><code>#!/bin/sh

dev=$(awk &#039;/*enabled/{print $1}&#039; /proc/acpi/wakeup)

for i in $dev ; do
   echo &quot;$i&quot; &gt; /proc/acpi/wakeup
done</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Wed, 14 Apr 2021 16:46:30 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29109#p29109</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Help with script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29108#p29108</link>
			<description><![CDATA[<p><a href="https://gist.github.com/npcardoso/47d8f45505ccbdb52581#file-acpi_wakeups-sh" rel="nofollow">https://gist.github.com/npcardoso/47d8f … wakeups-sh</a> has backticks round <span class="bbc">grep &#039;\*disabled&#039; /proc/acpi/wakeup | cut -d &#039; &#039; -f1</span> and <span class="bbc">grep &#039;\*enabled&#039; /proc/acpi/wakeup | cut -d &#039; &#039; -f1</span>. Those tell bash to run the command inside the backticks and assign the output from it to TOGGLE.</p><p>You could use $(...) instead, it&#039;s easier to read if you don&#039;t get muddled about what sort of brackets to use.</p><p>Chris</p>]]></description>
			<author><![CDATA[dummy@example.com (chris2be8)]]></author>
			<pubDate>Wed, 14 Apr 2021 16:39:12 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29108#p29108</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Help with script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29107#p29107</link>
			<description><![CDATA[<p>Hello:</p><div class="quotebox"><cite>dice wrote:</cite><blockquote><div><p>... need to be run as the root user?</p></div></blockquote></div><p>Yes, of course.</p><div class="codebox"><pre><code>groucho@devuan:~$ sudo ./acpi_wakeups.sh enable
./acpi_wakeups.sh: line 10: \*disabled: command not found
groucho@devuan:~$ </code></pre></div><div class="codebox"><pre><code>groucho@devuan:~$ sudo ./acpi_wakeups.sh disable
./acpi_wakeups.sh: line 14: \*enabled: command not found
groucho@devuan:~$ </code></pre></div><p>Just in case ...</p><div class="codebox"><pre><code>[root@devuan ~]# /home/groucho/acpi_wakeups.sh enable
/home/groucho/acpi_wakeups.sh: line 10: \*disabled: command not found
[root@devuan ~]# </code></pre></div><div class="codebox"><pre><code>[root@devuan ~]# /home/groucho/acpi_wakeups.sh disable
/home/groucho/acpi_wakeups.sh: line 14: \*enabled: command not found
[root@devuan ~]# </code></pre></div><p>Thanks for your input.</p><p>Best,</p><p>A.</p>]]></description>
			<author><![CDATA[dummy@example.com (Altoid)]]></author>
			<pubDate>Wed, 14 Apr 2021 15:47:54 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29107#p29107</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Help with script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29106#p29106</link>
			<description><![CDATA[<p>I believe that script would need to be run as the root user ?</p>]]></description>
			<author><![CDATA[dummy@example.com (dice)]]></author>
			<pubDate>Wed, 14 Apr 2021 15:25:54 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29106#p29106</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] Help with script]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=29105#p29105</link>
			<description><![CDATA[<p>Hello:</p><p>My <span class="bbc">/proc/acpi/wakeup</span> file reads thus:</p><div class="codebox"><pre><code>groucho@devuan:/proc/acpi$ cat wakeup
Device	S-state	  Status   Sysfs node
USB0	  S4	*enabled   pci:0000:00:1d.0
USB1	  S4	*enabled   pci:0000:00:1d.1
USB2	  S4	*enabled   pci:0000:00:1d.2
USB5	  S4	*disabled
EUSB	  S4	*enabled   pci:0000:00:1d.7
USB3	  S4	*enabled   pci:0000:00:1a.0
USB4	  S4	*enabled   pci:0000:00:1a.1
USB6	  S4	*enabled   pci:0000:00:1a.2
USBE	  S4	*enabled   pci:0000:00:1a.7
P0P1	  S4	*disabled  pci:0000:00:01.0
P0P2	  S4	*disabled  pci:0000:00:06.0
P0P3	  S4	*disabled  pci:0000:00:1c.0
BR11	  S4	*disabled
BR12	  S4	*disabled
BR13	  S4	*disabled
P0P4	  S4	*disabled  pci:0000:00:1c.4
BR15	  S4	*disabled
P0P5	  S4	*disabled  pci:0000:00:1e.0
GBE	  S4	*enabled   pci:0000:00:19.0
SLPB	  S4	*disabled
groucho@devuan:/proc/acpi$ </code></pre></div><p>I have no use for anything being enabled there and found a script to set everything to &#039;disabled&#039;:</p><p>See: <a href="https://gist.github.com/npcardoso/47d8f45505ccbdb52581#file-acpi_wakeups-sh" rel="nofollow">https://gist.github.com/npcardoso/47d8f … wakeups-sh</a></p><div class="codebox"><pre><code>#!/bin/bash
 
if [[ $# &gt; 1 || ($1 != &quot;enable&quot; &amp;&amp; $1 != &quot;disable&quot;) ]]; then
         echo &quot;Usage: $0 &lt;enable|disable&gt;&quot;
         exit 1
fi

if [[ $1 == &quot;enable&quot; ]]; then
        TOGGLE=grep &#039;\*disabled&#039; /proc/acpi/wakeup | cut -d &#039; &#039; -f1

else

        TOGGLE=grep &#039;\*enabled&#039; /proc/acpi/wakeup | cut -d &#039; &#039; -f1

fi

for DEV in $TOGGLE; do
        echo $DEV 
        echo $DEV &gt; /proc/acpi/wakeup

done</code></pre></div><p>For some reason it is not running properly.</p><div class="codebox"><pre><code>groucho@devuan:~$ ./acpi_wakeups.sh disable
./acpi_wakeups.sh: line 14: \*enabled: command not found
groucho@devuan:~$ </code></pre></div><div class="codebox"><pre><code>groucho@devuan:~$ ./acpi_wakeups.sh enable
./acpi_wakeups.sh: line 10: \*disabled: command not found
groucho@devuan:~$ </code></pre></div><p>Any help would be appreciated.</p><p>Thanks in advance,</p><p>A.</p>]]></description>
			<author><![CDATA[dummy@example.com (Altoid)]]></author>
			<pubDate>Wed, 14 Apr 2021 15:00:18 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=29105#p29105</guid>
		</item>
	</channel>
</rss>
