Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1
                                            S   Y   S   T   E   M           M   O   N   I   T   O   R           L   O   G
Linux system 4.4.0-22-generic #1 Sun Oct 9 20:21:24 EDT 2016
+GNU/Linux
Log report for righthere.home.org on Sun 23 Oct 2016 04:23:24 PM EDT
==============================================================

Search  for->   FAILED  starting    04:23:24    PM
Oct 23 16:23:04 righthere login[1769]: FAILED LOGIN 3 FROM (null) FOR
bball,
+Authentication failure

End of  /tmp/FAILED.logreport.102303    at  04:23:24    PM

To further automate the process, you can include command lines using the
script in another script to generate a series of searches and reports.


Built-in Variables


Built-in variables are special variables that Linux provides to the shell that
you can use to make decisions within a shell program. You cannot modify the
values of these variables within the shell program.


The following are some of the built-in variables:


$#—The  number  of  positional  parameters  passed  to  the shell   program
$?—The completion code of the last command or shell program executed
within the shell program (returned value)
$0—The name of the shell program
$*—A single string of all arguments passed at the time of invocation of
the shell program

To show these built-in variables in use, here is a sample program called
mypgm2:


Click here to view code image
#!/bin/sh
#my test program
echo "Number of parameters is $#"
echo "Program name is $0"
echo "Parameters as a single string is $*"


If you execute mypgm2 from the command line in pdksh and bash as
follows:


Click here to view code image
matthew@seymour:~$ bash mypgm2 Alan Turing

Free download pdf