Skip to main content
Engineering LibreTexts

Editors, IDEs, scripts, interpreters, and compiled code

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

      The basics of programming are writing instructions in a file.  If it is a script then an interpreter will be applied to run the file containing the instructions. 

      Examples of interpreters;

      1. bash
      2. sh
      3. perl
      4. python
      5. python3
      6. expect


      If the instructions are for compiled code like C\C++ then a compiler is used to make an executable.


      Editors and IDEs:

      For both scripts and compiled code instructions are placed into a file using an editor or IDE.

      These tools are for writing unformatted text to a file.  Unformatted text refers to raw ASCII characters as opposed to a word processor file of formatted text.



      Examples of command line editors on the RPi are vim and nano.



      The IDE is an integrated development environment for programming.  Examples of IDEs are shown here;

      1. Thonny
      2. Geany
      3. Greenfoot IDE

      The value of the IDE is the ability to run single lines or blocks of code for testing. Showing values contained in variables is also useful.

      The IDE is for development.  Development and testing often go together.  In a true Linux/IoT deployment environment there will not be a “run” button like in the IDE.  Testing often involves command line parameters.

      Command line parameters:

      Understanding command line parameters and using them is an important Linux/IoT skill.

      First examples of command line parameters, next how to get then in your scripts.


      pi@serverNine$ cat
      echo $ARG1 $VALX
      pi@serverNine$ bash arg1 valx
      arg1 valx

      The command “bash” is the first thing. The bash interpreter is a program, programs take command line parameters.  Here the first parameter is the text file named containing the commands to be interpreted.

      The script takes in the command line parameters arg1 and valx.

      pi@serverNine$ cat
      import sys
      pi@serverNine$ python3 ./ argx val1

      The python example above is essentially the same concept but using a different interpreter.


      Here is a Perl example;

      pi@serverNine$ cat
      my ($argOne, $valx) = @ARGV;
      print "arg1='$argOne' valx='$valx'\n";
      pi@serverNine$ perl ./ argx val1
      arg1='argx' valx='val1'

      From the examples above a pattern emerges.

      interpreter ./script.ext arg1 arg2 arg3 argN

      Making the script executable:

      Here is the outcome of running a bash script before setting the executable bit;

      pi@serverNine$ ls -l
      -rw-r--r-- 1 pi pi 37 Aug 12 15:07
      pi@serverNine$ ./
      -bash: ./ Permission denied

       After setting the executable bit;

      pi@serverNine$ chmod +x
      pi@serverNine$ ls -l
      -rwxr-xr-x 1 pi pi 37 Aug 12 15:07
      pi@serverNine$ ./
      pi@serverNine$ ./ arg1 valx
      arg1 valx


      After setting the executable bit;

      Notice that “bash” is not at the front of the command.

      What interpreter is being used here?

      The answer is the default interpreter. For many distributions of Linux bash is the default interpreter.  For some situations bash is not the default interpreter, for example, in a cronjob.

      Good programming practice is to set the interpreter when you first start writing your script.

      First is to find the interpreter you want.  Here is how for bash;


      pi@serverNine$ which bash


      Here is how to use it to set the interpreter in your bash script;

      echo $ARG1 $VALX

      The script is saved with the first line as follows;


      A pattern emerges.

      For python use;

      which python


      For python3.

      which python3


      In the top of a python3 script set the interpreter from the output of the which command as follows;


      The ‘#’ is a comment, therefore not a statement for the interpreter.

      The ‘!’ tells the OS that the interpreter to use is next, (/usr/bin/python3).


      The general method for scripts is as follows;

      Put the interpreter in the top of the file and set the executable bit.


      Compile C code:

      C++ Programming/Examples/Hello world

      // 'Hello World!' program
      #include <iostream>
      int main()
        std::cout << "Hello World!" << std::endl;
        return 0;

      Save the C++ code above in a file named

      Compile the code using the following command;

      g++ -o hello

      Run the compiled code as follows;

      pi@serverNine$ ./hello 
      Hello World!


      Mix and match:

      Success is often based on the choice of the right tools for the job.

      Here the tools are the OS, in this case Linux, and the programming/scripting language.

      Often the bash script is used as the main driver, calling other programs/scripts as appropriate to the job.

      In this example the compiled program “hello” will be used as a stand in for sensor data collection.  A bash script is the main driver calling the sensor program “hello”.

      # Get data from sensor named "hello"
      echo data from sensor 
      echo $DATA

      Run the main driver script;

      pi@serverNine$ ./ 
      data from sensor
      Hello World!

      In this next example the bash main driver is calling a python3 script called "".

      print("Hello World!")

      The modified bash main driver "".

      # Get data from sensor named ""
      echo data from sensor 
      echo $DATA

      Run the main driver script;

      pi@serverNine$ ./
      data from sensor
      Hello World!

      In the next example the python3 “” script is used as the main driver for calling the bash script “”.

      import subprocess
      # returns output as byte string
      returned_output = subprocess.check_output("./")

      Output from running the python3 “” script;

      pi@serverNine$ ./
      data from sensor
      Hello World!

      It is important to point out here that having a python3 main driver, calling a bash script that calls a python script is not an optimal approach.  These examples only serve to point out the possibilities in terms of the mix and match of tools and choices.





      Editors, IDEs, scripts, interpreters, and compiled code is shared under a GNU General Public License 3.0 license and was authored, remixed, and/or curated by LibreTexts.

      • Was this article helpful?