Give multiple terminal commands in a single file and run all the commands at once?
<p>I'm a beginner into Raspberry pi and i have a basic doubt.</p>

<p>I'm basically trying to make my raspberry pi into a beacon and advertise data from it to a Android app. </p>

<p>I wonder if I can give multiple terminal commands in a single file and run all the commands simply by compiling and running the file?</p>

<p>I followed <a href="https://learn.adafruit.com/pibeacon-ibeacon-with-a-raspberry-pi/overview" rel="nofollow">this tutorial</a>. </p>

<p>My basic doubt is that, each time i have to check if a device is available(bluetooth) and advertise it, it takes a command for each of this. Can i integrate multiple raspberry pi commands into a file and run all these commands simply by compiling and running the file (as a script)?</p>

<p>Few of the commands are as follows :</p>

<pre><code>sudo hcitool lescan, 
sudo hcitool hci0,
sudo hcitool -i hci0 0x008,
</code></pre>

<p>and few commands like these..</p>

<p>Say you have a file <code>example.txt</code> with your commands:</p>

<pre><code>sudo hcitool lescan
sudo hcitool hci0
sudo hcitool -i hci0 0x008
</code></pre>

<p>Then you can execute those commands by running <code>sh example.txt</code> or <code>bash example.txt</code>.
See <a href="http://stackoverflow.com/questions/9825495/ubuntu-run-text-file-as-command">ubuntu run text file as command</a></p>

python linux raspberry-pi bluetooth-lowenergy ibeacon