How to create a selection menu using the select statement in Bash shell

How to create a selection menu using the select statement in Bash shell

We all very often use bash scripts to automatize boring and repetitive tasks. Sometimes in our scripts we need to ask
the user to perform one or more choices interactively: in this tutorial we will see how to use the Bash shell select statement to perform such operation in very few lines of code.

In this tutorial you will learn:

  • How to use the Bash select statement
  • How to customize the select menu prompt

Read more

PostgreSQL performance tuning for faster query execution

Objective

Our objective is to make a dummy query execution run faster on PostgreSQL database using only the built in tools available
in the database.

Operating System and Software Versions

  • Operating System: Red Hat Enterprise Linux 7.5
  • Software: PostgreSQL server 9.2

Requirements

PostgreSQL server base install up and running. Access to the command line tool psql and ownership of the example database.

Read more

python-logo-requests-standard-library

How to perform HTTP requests with python – Part 1: The standard Library

HTTP is the protocol used by the World Wide Web, that’s why being able to interact with it programmatically is essential: scraping a web page, communicating with a service APIs, or even simply downloading a file, are all tasks based on this interaction. Python makes such operations very easy: some useful functions are already provided in the standard library, and for more complex tasks it’s possible (and even recommended) to use the external requests module. In this first article of the series we will focus on the built-in modules. We will use python3 and mostly work inside the python interactive shell: the needed libraries will be imported only once to avoid repetitions.

In this tutorial you will learn:

  • How to perform HTTP requests with python3 and the urllib.request library
  • How to work with server responses
  • How to download a file using the urlopen or the urlretrieve functions

Read more

radiolist-widget

How to use ncurses widgets in shell scripts on Linux

In this tutorial we will learn the basics of the dialog utility, in order to use ncurses widget in our shell scripts. We will see how to install dialog in the most used Linux distributions, some of the common options we can use to alter the behavior of dialog, how to use some widgets; among the others: inputbox, checklist, radiolist and yesno. Finally, we will see how to use the data obtained by the widget processing.

In this tutorial you will learn:

  • How to install the dialog utility on Linux
  • What are the most relevant dialog options
  • How to use the inputbox, checklist, radiolist, passwordbox, msbox, calendar and yesno widgets
  • How to manage data derived from the widget processing

Read more

python-logo-requests-requests-library

How to perform HTTP requests with python – Part 2 – The request Library

In the previous article we saw how to perform basic HTTP requests using the python3 standard library. When requests become more complex, or we just want to use less code, and we don’t mind adding a dependency to our project, it’s possible (and sometimes even recommended) to use the external requests module. The library, which adopted the “HTTP for Humans” motto, will be the focus of this article.

In this tutorial you will learn:

  • How to perform HTTP requests with python3 and the ‘requests’ library
  • How to manage server responses
  • How to work with sessions

Read more

Verifying changes with grep

How to create a hot standby with PostgreSQL

Objective

Our objective is to create a copy of a PostgreSQL database that is constantly synchronizing with the original one and accepts read-only queries.

Operating System and Software Versions

  • Operating system: Red Hat Enterprise Linux 7.5
  • Software: PostgreSQL server 9.2

Requirements

Privileged access to both master and slave systems

Read more

union-statement-result

How to combine the results of multiple SQL queries using the UNION statement

In a previous article we talked about the various type of JOIN we can use in a MariaDB/MySQL database. This time, instead, we take a look at the UNION statement: how it works, how we can use it to combine the result of queries run on different tables, and what are its peculiarities.

In this tutorial you will learn:

  • How to use the UNION statement in a MariaDB/MySQL server
  • What are the properties of the UNION statement

Read more

python-logo

How to create and manipulate tar archives using Python

On Linux and other Unix-like operating systems, tar is undoubtedly one of the most used archiving utilities; it let us create archives, often called “tarballs”, we can use for source code distribution or backup purposes. In this tutorial we will see how to read, create and modify tar archives with python, using the tarfile module.

In this tutorial you will learn:

  • The modes in which a tar archive can be opened using the tarfile module
  • What are the TarInfo and TarFile classes and what they represent
  • How to list the content of a tar archive
  • How to extract the content of a tar archive
  • How to add files to a tar archive

Read more

javascript-fetch-api

Introduction to the JavaScript Fetch API

Compared to XMLHttpRequest and the libraries built around it, like JQuery.ajax, the fetch API defines a more modern and cleaner way of performing asynchronous requests, based on the use of promises. In this article we will see some of the interfaces provided by the API, like Request and Response, and we will learn how to use the fetch method to perform various types of asynchronous requests.

In this tutorial you will learn:

  • How to send asynchronous requests using the fetch method
  • How to work with the Request and Response objects provided by the fetch API

Read more