• Debugging the shell scripts
  • 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
    bet165/203
    Sana10.01.2024
    Hajmi6,34 Mb.
    #134102
    1   ...   161   162   163   164   165   166   167   168   ...   203
    Bog'liq
    Linux This Book Includes 4 Manuscripts The Underground Bible

    First shell script
    Let us create a shell script of the name sample.sh. create a shell script using
    the following command.
    cat sample.sh
    Location of the shell program
    echo " This is very regressive"
    Now we will explain this in detail. Line by line.
    a) #! This represents the starting of a shell script that we are trying to write .
    b) If it starts with only a hash # then it is called a comment. Comments are
    annotations that are used to make it easy for reference or for other users that
    want to look at the code. It may seem unnecessary to write comments for
    small shell scripts. But it is a good practice to start writing comments.
    c) echo is a shell default command that lets the interpreter display the
    content that is written.
    Here to run the shell you need to use the following command:
    bash sample.sh
    And then the output will appear
    For this example, the output is as follows:
    This is very regressive 


    There is also another feature that will let you run the script with additional
    permissions. As we discussed earlier Linux has a set of permissions and if
    you don't provide with necessary permissions the script may not run
    perfectly. So, to provide permission use the following command
    In the next section, we will start discussing the debugging of the shell
    scripts. Debugging is one of the most important programming tasks. Even
    hackers need to be perfect at this because wrong debugging of code may
    result in bad adaptation of the task. 
    Debugging the shell scripts 
    Normally when you enter a wrong default command in the script such as
    shown below in the code.
    vulnerhost @ example: ech 7898
    This code will not run and show an error as shown below
    the ech command is not found
    This is exactly what debugging is. Debugging features informs the user
    about the errors in the script.
    There are also a lot of shell debugging tools that perform the tasks we do in
    a command-line interface. Tools like bashdb are famous for this. In the next
    section, we will learn in detail about a handful number of important bash
    built-in commands. This section will help hackers understand the basics of
    shell programming effectively. Let's go !

    Download 6,34 Mb.
    1   ...   161   162   163   164   165   166   167   168   ...   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