Linux: This Book Includes 4 Manuscripts. The Underground Bible to the unix operating System with Tools On Security and Kali Hacking to Understand Computer Programming, Data Science and Command Line




Download 6,34 Mb.
Pdf ko'rish
bet112/203
Sana10.01.2024
Hajmi6,34 Mb.
#134102
1   ...   108   109   110   111   112   113   114   115   ...   203
Bog'liq
Linux This Book Includes 4 Manuscripts The Underground Bible

Creating a bash script
When one is creating a bash script, they need to tell the computer that they
are creating a bash script. The way to achieve this is through typing
#!/bin/bash . This command will inform the computer that a bash script is
being made. This will be followed by the commands that the user wants the
program to display. There is a syntax that should be used when scripting.
For example, when the user wants the computer to display something when
the program is run, they will use the syntax echo followed by what they
want to say in quotes. For example, you want the program to display the
word welcome after it is run on the script; one will type the following:
echo “welcome.”
When the program is run, it will display the word welcome on the screen.
To input time between the response of the program and the next action, one
will use the syntax sleep followed by the length of time they want the pause
to be. For example
Sleep 5, the command will mean that the program will always pause for five
seconds before it can execute the next command. When done one will
simply press CTRL + X to exist, and they will be asked to save the file
according to the name they gave the program. It is important to note that
bash scripts can be very long. The size of the script will rely on the number
of simultaneous activities that one wants the program to run automatically
without the user having to get involved. For example, when one presses the
shut down button on a computer, the computer runs on a bash script that
allows it to save all the work and close the running applications
automatically before it can power off. All these activities follow a bash
script and so do many applications and actions on a computer. 
Once a person has saved the bash script, they have to make the script
executable. This involves changing the mode of the script to a version that
is executable. Changing the mode will involve the user type the following.
Chmod +X
After this step, the user will then type
./ then press enter
Once you press enter, the script will run according to how it was input and
executed. The bash script will also include more syntax and commands that
will help to condense the many commands that are run manually but can be
run automatically. This will ensure that the user does not have to do too


much, but rather the program will run automatically. The bash script,
therefore, provides the program with a certain level of automation.

Download 6,34 Mb.
1   ...   108   109   110   111   112   113   114   115   ...   203




Download 6,34 Mb.
Pdf ko'rish

Bosh sahifa
Aloqalar

    Bosh sahifa



Linux: This Book Includes 4 Manuscripts. The Underground Bible to the unix operating System with Tools On Security and Kali Hacking to Understand Computer Programming, Data Science and Command Line

Download 6,34 Mb.
Pdf ko'rish