Linux Shell Scripting – Functions

How do I create a shell script function using Bash under UNIX / Linux operating systems?

Functions are nothing but small subroutines or subscripts within a Bash shell script. You need to use to break up a complex script into separate tasks. This improves overall script readability and ease of use. However, shell function cannot return value. They return a status code.

All functions must be declared before they can be used.

function welcome(){
  Commands
}

OR

 
welcome(){
 Commands
 return $TRUE
}

You can call function by typing its name:

 
welcome

Read more

Mail Queue Management Exim

Managing emails can be cumbersome when you need to look into several things such as removing spam mails, Frozen mails, Bounce mails, Queue force rerun, among others.

Now, from our experience, we are sharing some commonly used commands below for managing Exim Servers:

To get the total number of mails in the queue

# exim -bpc

To list the mails in the queue

# exim -bp

Used to remove the message from queue with Exim Id : 1VcjOL-0002YV-8g

# exim -Mrm 1VcjOL-0002YV-8g

Read more

Linux Shell Scripting – An Introduction

Linux Shell Scripting

Scripts are collections of commands that are stored in a file. The shell can read this file and act on the commands as if they were typed at the keyboard. The shell also provides a variety of useful programming features to make your scripts truly powerful.

Write a simple shell script

Use an editor software to write the script. The following is the simplest “Hello World” program.

#!/bin/sh
# My first script
echo "Hello World!"

and save the above script to the file name “myScript.sh”

We can use any name for saving the script. but here I am using “.sh” extension for my script, since the shell used here is “/bin/sh”. Also it will help us to identify the scripts from a other files and folders.

Read more