<?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[using terminal commands results in variable does not work in PYTHON]]></title><description><![CDATA[<p dir="auto">I am trying to read the brightness parameter of blue Led of omega2 to use it in a variable to use this to manage a led in my frontplate of my box with omega 2lte. I do not know what i do wrong.  here is the essential part of the python script I use:</p>
<p dir="auto">while True:<br />
w = os.system("cat /sys/class/leds/omega2lte:blue:wifi/brightness")<br />
if w == 255:<br />
status2 = "connected"<br />
status = gpioObj.setValue(0)<br />
print(status2)</p>
<p dir="auto">The  frontplate shows if I am connected to my application via mobile ( iot ) or via wifi, if there is no good radio connection to mobile iot<br />
If I look in logread I see that the cat command shows the correct value of 255 and  but the ïf in  the programm does not see the variable.<br />
Van some body help me with this?</p>
]]></description><link>http://community.onion.io/topic/4609/using-terminal-commands-results-in-variable-does-not-work-in-python</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 13:52:16 GMT</lastBuildDate><atom:link href="http://community.onion.io/topic/4609.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 18 Nov 2021 17:51:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to using terminal commands results in variable does not work in PYTHON on Thu, 18 Nov 2021 17:51:23 GMT]]></title><description><![CDATA[<p dir="auto">I am trying to read the brightness parameter of blue Led of omega2 to use it in a variable to use this to manage a led in my frontplate of my box with omega 2lte. I do not know what i do wrong.  here is the essential part of the python script I use:</p>
<p dir="auto">while True:<br />
w = os.system("cat /sys/class/leds/omega2lte:blue:wifi/brightness")<br />
if w == 255:<br />
status2 = "connected"<br />
status = gpioObj.setValue(0)<br />
print(status2)</p>
<p dir="auto">The  frontplate shows if I am connected to my application via mobile ( iot ) or via wifi, if there is no good radio connection to mobile iot<br />
If I look in logread I see that the cat command shows the correct value of 255 and  but the ïf in  the programm does not see the variable.<br />
Van some body help me with this?</p>
]]></description><link>http://community.onion.io/post/24124</link><guid isPermaLink="true">http://community.onion.io/post/24124</guid><dc:creator><![CDATA[kottes]]></dc:creator><pubDate>Thu, 18 Nov 2021 17:51:23 GMT</pubDate></item><item><title><![CDATA[Reply to using terminal commands results in variable does not work in PYTHON on Wed, 24 Nov 2021 05:00:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/7905">@kottes</a><br />
Looks like os.system() is  not passing the result of cmd to w.</p>
<p dir="auto">Try this:</p>
<blockquote>
<blockquote>
<p dir="auto">import subprocess<br />
cmd = "cat  /sys/class/leds/input3::numlock/brightness"<br />
ret = subprocess.check_output(cmd, shell = True).strip()<br />
if ret == b'1':<br />
print("NumLock ON")</p>
</blockquote>
</blockquote>
<p dir="auto">Thanks.</p>
]]></description><link>http://community.onion.io/post/24136</link><guid isPermaLink="true">http://community.onion.io/post/24136</guid><dc:creator><![CDATA[tjoseph1]]></dc:creator><pubDate>Wed, 24 Nov 2021 05:00:08 GMT</pubDate></item><item><title><![CDATA[Reply to using terminal commands results in variable does not work in PYTHON on Wed, 24 Nov 2021 16:59:48 GMT]]></title><description><![CDATA[<p dir="auto">Why don't you just read the (pseudo) file? No need to open new processes. Using</p>
<pre><code>w = int(open('/sys/class/leds/omega2lte:blue:wifi/brightness').read())
</code></pre>
<p dir="auto">Will give you what you need from python in a pythonic way.</p>
]]></description><link>http://community.onion.io/post/24140</link><guid isPermaLink="true">http://community.onion.io/post/24140</guid><dc:creator><![CDATA[victoriano]]></dc:creator><pubDate>Wed, 24 Nov 2021 16:59:48 GMT</pubDate></item></channel></rss>