Hardware Reference
In-Depth Information
You can define your own environmental variables easily in bash. By convention, in
bash, all environmental variables are defined using capital letters.
To define an environmental variable, you can do as shown in the following screenshot:
Defining the MY_VARIABLE environmental value
Environmental variables can be used just as easily. To use an environmental variable,
simply add $ before it.
Using the MY_VARIABLE environmental value
Environmental variables are often used in shell scripts to store information and results.
Do you know that a bug called Shellshock was discovered in 2014 in
bash's handling of environmental variables? This bug allowed the
execution of arbitrary commands and presented a huge risk to many of
the web servers running on the Internet.
It is easy to add an environmental variable. To do this, you use the export command
as follows:
export VARIABLE=value
An environmental variable's name can't contain a space and must contain capital letters.
Basic scripting
All the commands that you have seen so far are just single commands. The bash
has the ability to execute multiple commands together in one go. Commands can
be stored in a file called a shell script.
A shell script has its execute attribute set. It can then be run by simply changing
into the directory that the script is in and typing its name.
These shell scripts can be run as normal program a on your Raspberry Pi.
 
Search WWH ::




Custom Search