Build your program step by step using Shell Scripting - Part 6

Reviewing what we have seen so far in the series of posts called "Build your program step by step using Shell Scripting" we have studied seen examples of how to create the following modules:

Shell scripting

In this new edition, the sixth (6), we will cover the study of the following module:

ARCHITECTURE DETECTION MODULE

This module will allow you to consider, depending on the Architecture of the Operating System where it is executed, both its validation and subsequent actions scheduled based on said data.

Its content would be the following:


###############################################################################
# INICIO DEL MODULO DE DETECCIÓN DE ARQUITECTURA DEL LPI-SB
###############################################################################

read -p "Introduzca la Arquitectura de su Sistema Operativo (1 = 32Bit / 2 = 64Bit): " ARQ
echo ""

while [[ $ARQ != "1" && $ARQ != "2" ]]

do

echo -e '\a'

echo ""
echo ""
echo "#-----------------------------------------------------------------#"
echo "# LA ARQUITECTURA POR USTED INDICADA NO COINCIDE CON LO SOLICITADO#"
echo "#-----------------------------------------------------------------#"
echo ""
echo ""

read -p "PRESIONE 1 ó 2 para continuar: " ARQ
echo ""

done

if [[ "$ARQ" == "1" ]]; then
   ARQ_A=x86
   ARQ_B=i386
  else
   ARQ_A=x86_64
   ARQ_B=amd64
fi

echo "La arquitectura seleccionadas fueron" $ARQ_A "y" $ARQ_B "según sus datos."
sleep 3

if [[ "$ARQ_A" == "$ARQ_DISTRO_COD" ]]; then

echo -e '\a'

echo ""
echo ""
echo "#--------------------------------------------------------------#"
echo "# LA ARQUITECTURA POR USTED INDICADA COINCIDE CON LA DETECTADA #"
echo "#--------------------------------------------------------------#"
echo ""
echo ""

sleep 3
clear

  else

echo -e '\a'

echo ""
echo ""
echo "#-----------------------------------------------------------------#"
echo "# LA ARQUITECTURA POR USTED INDICADA NO COINCIDE CON LA DETECTADA #"
echo "#-----------------------------------------------------------------#"
echo ""
echo ""

fi

read -p "SI DESEA CANCELAR EL PROCESO HASTA AHORA PRESIONE CUALQUIERA DE LOS SIGUIENTES CARACTERES: "s" "S" "y" "Y". DE LO CONTRARIO PRESIONE CUALQUIER OTRA TECLA PARA CONTINUAR, RECUERDE QUE TRABAJAR CON LA ARQUITECTURA INCORRECTA PUEDE TRAERLE SERIOS INCONVENIENTES AL LPI-SB PARA TRABAJAR OPTIMAMENTE! : " op

if [[ $op == "y" || $op == "Y" || $op == "s" || $op == "S" ]];

 then

   sleep 3 ; clear ; exit 0

 else

   sleep 3 ; clear ; read -p "EL SCRIPT LPI-SB PROCEDERA HA CONTINUAR, PRESIONE CUALQUIER TECLA PARA CONTINUAR..." && sleep 3 ; clear

fi

################################################################################
# FINAL DEL MODULO DE DETECCIÓN DE ARQUITECTURA DEL LPI-SB
################################################################################

When analyzing this code, we realize that the first thing said module does is ask the user for the following:

Enter the Architecture of your Operating System (1 = 32Bit / 2 = 64Bit)

Depending on the value entered, the module performs the following evaluation:

It is the entered value equal to 1 or 2

In case it is not equal to any of the 2 values, the module repeats the read request until it is equal to one of the 2 required values. In case of being equal to one of them, the module performs the following evaluation:

If the entered value is equal, one 1), variables $ ARQ_A y $ ARQ_B are configured with the values x86 y i386 correspondingly and are displayed on the screen, if it is two 2) the stored values ​​would be: x86_64 y amd64.

Then compare the value of $ ARQ_A with $ ARQ_DISTRO_COD whose value is equal to the command output: join me -m, previously loaded in the Environment Variables module of the same program.

If the 2 values ​​are the same, it issues the following message on the screen:

THE ARCHITECTURE INDICATED BY YOU MATCHES THE ONE DETECTED

If they are different, this one:

THE ARCHITECTURE INDICATED BY YOU DOES NOT COINCIDE WITH THE ONE DETECTED

Ending with the last warning message to the user that says:

IF YOU WANT TO CANCEL THE PROCESS UNTIL NOW PRESS ANY OF THE FOLLOWING CHARACTERS: «s» «S» «and» «Y». OTHERWISE, PRESS ANY OTHER KEY TO CONTINUE, REMEMBER THAT WORKING WITH THE INCORRECT ARCHITECTURE MAY BRING SERIOUS DISADVANTAGES TO THE LPI-SB TO WORK OPTIMALLY!

If the user presses some of the correct characters, the program closes and otherwise it issues the following message and continues its operation:

THE LPI-SB SCRIPT WILL PROCEED TO CONTINUE, PRESS ANY KEY TO CONTINUE ...

=============

RECOMMENDED READING:

WHAT CAN STATES (NATIONS) AND SOCIETIES (PEOPLES) WIN BY CREATING CENTRALIZED APPLICATIONS IN FREE SOFTWARE, OPEN SOURCE AND INTERNET-BASED (CLOUD)?

In my very particular opinion, I think that considering the pressing needs of monitoring, control, unification of criteria and procedures, centralization of efforts, saving financial resources and hours / labor of the valuable and scarce specialized human resources in different labor fields of any National Public Administration (APN) from a poor and / or developing country, the profit goes search-oriented solutions and mimprovements de the real needs of the social environments in which these societies and public institutions operate, at a low cost and in an innovative, modern, scalable and transparent way, assuming from within (Government) and from without (People / Society), joint responsibility for the success of public policies of that State (Nation), thus strengthening the commitment to the country by both actors, within the framework of the construction of the socio-political, economic and technological project that you plan to apply.

And how is this justified before the Governments or the Peoples?

We must emphasize that at present, a series of changes are taking place in the world in the way in which the States (Governments) and in their responsibility to society, which has required that the search for efficiency, effectiveness, visibility and publicity (Communication of public management), are an essential imperative, not only in issues associated with citizens, such as poverty, health, environment, education and everything in general, yes no also in the solution to the problems that exist in the management and operation of monitoring and control of public policies that operate in the institutions that make up any National State, especially those that are in a continuous optimization and restructuring processes towards new models that provide the higher quality of life for its inhabitants.

Similarly, the role of citizenship has also been transforming, through use of much more innovative and diverse forms of expression, direct and powerful, based on the use of Information and Communication Technologies (ICT), the same, that most developed countries, have already been implemented and massifying inside and outside their APNs for the benefit of their citizens.

And taking into account that public institutions in poor or developing countries, have an important conglomerate of process and document based informationI know they should be uniforms (standardized), Y de projects and works in progress that are oriented to the direct benefit of their nationals (inhabitants), the creation of Applications or Systems based on Open Source, Free Software running on the Internet (Cloud) would serve as a platform to channel and enhance the aforementioned elements, making the concept of ELECTRONIC GOVERNMENT more efficient, enhancing operations within public institutions, taking advantage of advances in technology to guarantee better communication and intergovernmental interaction between all the entities of said State.

In short, using Open Source, Free Software and the Internet easily any STATUS could to low cost, in a modern, transparent and safe waya give an answer to the following basic questions that every State or Government must do:

  • How to make the internal governmental processes and the public policies implemented more effective and efficient, in line with the increase in the pertinent measures and controls for their monitoring and control?

  • How to protect and optimize the resources (material, technological and human) of the State?

  • How to achieve innovation within rigid administrative structures to achieve institutional and social challenges (goals)?

  • ¿How to improve satisfaction and public appreciation to Go managementgood?

  • How to advance in achievements in the field of Electronic Government?

In summary, The good implementation of ICT using Open Source, Free Software and the Internet would facilitate rapid progress in the social development of any nation, since together with the best human resources, a State would obtain the best support to automate the different plans of development of its institutions, optimizing and accelerating the processes and response times that are managed within itself.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.