<?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[Controlling my Pi via bash script on buttonclick]]></title><description><![CDATA[<p dir="auto">Thanks for reading my post. I want to understand how to make a simple application that will run shell script on the local system. For example, I've written a simple bash to control specific pins on my pi.</p>
<p dir="auto">@<br />
while : # Loop forever<br />
do</p>
<ol>
<li>
<p dir="auto">Start Pin 12</p>
</li>
<li>
<p dir="auto">Stop Pin 12</p>
</li>
<li>
<p dir="auto">Start Pin 16</p>
</li>
<li>
<p dir="auto">Stop Pin 16</p>
</li>
<li>
<p dir="auto">Exit prog<br />
!</p>
</li>
</ol>
<p dir="auto">echo -n " Your choice? : "<br />
read choice</p>
<h1>All the scripting goes here</h1>
<p dir="auto">sta_pin12 () {<br />
echo "12" &gt; /sys/class/gpio/export<br />
echo "out" &gt; /sys/class/gpio/gpio12/direction<br />
echo "0" &gt; /sys/class/gpio/gpio12/value<br />
echo "GPIO 12 started"<br />
echo "12" &gt; /sys/class/gpio/unexport<br />
}</p>
<p dir="auto">sto_pin12 () {<br />
echo "12" &gt; /sys/class/gpio/export<br />
echo "1" &gt; /sys/class/gpio/gpio12/value<br />
echo "GPIO 12 stoped"<br />
echo "12" &gt; /sys/class/gpio/unexport<br />
}</p>
<p dir="auto">sta_pin16 () {<br />
echo "16" &gt; /sys/class/gpio/export<br />
echo "out" &gt; /sys/class/gpio/gpio16/direction<br />
echo "0" &gt; /sys/class/gpio/gpio16/value<br />
echo "GPIO 16 started"<br />
echo "16" &gt; /sys/class/gpio/unexport<br />
}</p>
<p dir="auto">sto_pin16 () {<br />
echo "16" &gt; /sys/class/gpio/export<br />
echo "1" &gt; /sys/class/gpio/gpio16/value<br />
echo "GPIO 16 stoped"<br />
echo "16" &gt; /sys/class/gpio/unexport<br />
}</p>
<h1>menu order</h1>
<p dir="auto">case $choice in</p>
<ol>
<li>sta_pin12 ;;</li>
<li>sto_pin12 ;;</li>
<li>sta_pin16 ;;</li>
<li>sto_pin16 ;;</li>
<li>exit ;;<br />
*) echo ""$choice" is not valid "; sleep 2 ;;<br />
esac<br />
done<br />
@</li>
</ol>
<h1>And this works just fine. However I want a simple pushbutton gui, so I created a project in Qt. I created a button, right click, Go to slot and I see this coding:</h1>
<p dir="auto">@<br />
#include "mainwindow.h"<br />
#include "ui_mainwindow.h"</p>
<p dir="auto">MainWindow::MainWindow(QWidget *parent) :<br />
QMainWindow(parent),<br />
ui(new Ui::MainWindow)<br />
{<br />
ui-&gt;setupUi(this);<br />
}</p>
<p dir="auto">MainWindow::~MainWindow()<br />
{<br />
delete ui;<br />
}</p>
<p dir="auto">void MainWindow::on_pushButton_clicked()<br />
{</p>
<p dir="auto">}<br />
@</p>
<p dir="auto">==========================================================================<br />
What coding do I enter between the brackets above to achieve the following commands below?</p>
<p dir="auto">@<br />
echo "12" &gt; /sys/class/gpio/export<br />
echo "out" &gt; /sys/class/gpio/gpio12/direction<br />
echo "0" &gt; /sys/class/gpio/gpio12/value<br />
echo "12" &gt; /sys/class/gpio/unexport<br />
@</p>
<p dir="auto">I program <a href="http://vb.net" target="_blank" rel="noopener noreferrer nofollow ugc">vb.net</a> for windows and am totally new at Qt, any help is most appreciated!</p>
<p dir="auto"><em>[edit: added missing coding tags @ SGaist]</em></p>
]]></description><link>https://forum.qt.io/topic/45166/controlling-my-pi-via-bash-script-on-buttonclick</link><generator>RSS for Node</generator><lastBuildDate>Mon, 18 May 2026 19:03:47 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/45166.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 23 Aug 2014 19:22:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Controlling my Pi via bash script on buttonclick on Mon, 25 Aug 2014 21:55:54 GMT]]></title><description><![CDATA[<p dir="auto">You're welcome :)</p>
<p dir="auto">Since you have it running now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)</p>
]]></description><link>https://forum.qt.io/post/241219</link><guid isPermaLink="true">https://forum.qt.io/post/241219</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 25 Aug 2014 21:55:54 GMT</pubDate></item><item><title><![CDATA[Reply to Controlling my Pi via bash script on buttonclick on Sun, 24 Aug 2014 22:55:46 GMT]]></title><description><![CDATA[<p dir="auto">yup removed quotation from 12 and out, works just fine. I had quotes originally because part of the bash was calling variable from menu. thnx guys</p>
]]></description><link>https://forum.qt.io/post/241046</link><guid isPermaLink="true">https://forum.qt.io/post/241046</guid><dc:creator><![CDATA[WDTG]]></dc:creator><pubDate>Sun, 24 Aug 2014 22:55:46 GMT</pubDate></item><item><title><![CDATA[Reply to Controlling my Pi via bash script on buttonclick on Sun, 24 Aug 2014 18:40:39 GMT]]></title><description><![CDATA[<p dir="auto">AFAIK, the formatting of your echo lines are invalid in bash.</p>
<p dir="auto">Have a look at QProcess, it should make things easier</p>
]]></description><link>https://forum.qt.io/post/241019</link><guid isPermaLink="true">https://forum.qt.io/post/241019</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 24 Aug 2014 18:40:39 GMT</pubDate></item><item><title><![CDATA[Reply to Controlling my Pi via bash script on buttonclick on Sun, 24 Aug 2014 04:22:17 GMT]]></title><description><![CDATA[<p dir="auto">sorry for formatting</p>
<p dir="auto">system(“echo “12” &gt; /sys/class/gpio/export”);<br />
system(“echo “out” &gt; /sys/class/gpio/gpio12/direction”);<br />
system(“echo “0” &gt; /sys/class/gpio/gpio12/value”);<br />
system(“echo “12” &gt; /sys/class/gpio/unexport”);</p>
]]></description><link>https://forum.qt.io/post/240957</link><guid isPermaLink="true">https://forum.qt.io/post/240957</guid><dc:creator><![CDATA[WDTG]]></dc:creator><pubDate>Sun, 24 Aug 2014 04:22:17 GMT</pubDate></item><item><title><![CDATA[Reply to Controlling my Pi via bash script on buttonclick on Sun, 24 Aug 2014 04:16:49 GMT]]></title><description><![CDATA[<p dir="auto">system call works but not with the syntax I have. I use system to call a bash sript it works fine but if I use</p>
<pre><code>system&amp;#40;"echo “12” &gt; /sys/class/gpio/export"&amp;#41;;
system&amp;#40;"echo “out” &gt; /sys/class/gpio/gpio12/direction"&amp;#41;;
system&amp;#40;"echo “0” &gt; /sys/class/gpio/gpio12/value"&amp;#41;;
system&amp;#40;"echo “12” &gt; /sys/class/gpio/unexport"&amp;#41;;
</code></pre>
<p dir="auto">I get nothing, is it because of the quotes after echo. I know in vb,net you must double quote, but that didn't work either. :(</p>
]]></description><link>https://forum.qt.io/post/240956</link><guid isPermaLink="true">https://forum.qt.io/post/240956</guid><dc:creator><![CDATA[WDTG]]></dc:creator><pubDate>Sun, 24 Aug 2014 04:16:49 GMT</pubDate></item><item><title><![CDATA[Reply to Controlling my Pi via bash script on buttonclick on Sun, 24 Aug 2014 02:49:45 GMT]]></title><description><![CDATA[<p dir="auto">Welcome to the forum. Do you want run the shell script from Qt or you want to write the commands to file ? Question heading was different from what you are asking inside the question. If you want to write into file  SGaist has already answered it. If you want to run the shell script, look at the QProcess or system call.</p>
]]></description><link>https://forum.qt.io/post/240955</link><guid isPermaLink="true">https://forum.qt.io/post/240955</guid><dc:creator><![CDATA[dheerendra]]></dc:creator><pubDate>Sun, 24 Aug 2014 02:49:45 GMT</pubDate></item><item><title><![CDATA[Reply to Controlling my Pi via bash script on buttonclick on Sat, 23 Aug 2014 22:22:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">You need to write to these files so QFile should be your friend</p>
<p dir="auto">Hope it helps</p>
]]></description><link>https://forum.qt.io/post/240951</link><guid isPermaLink="true">https://forum.qt.io/post/240951</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sat, 23 Aug 2014 22:22:59 GMT</pubDate></item></channel></rss>