Thursday, April 30, 2009

How TO - Multiple grep Search Pattern

bash-2.03$ cat benchmark.out |egrep -e "SOLARIS26SPARC"
  P4D/SOLARIS26SPARC/2006.1/109255 (2006/10/17)
  P4/SOLARIS26SPARC/2006.1/104454 (2006/08/11)

bash-2.03$ cat benchmark.out |egrep -e "SOLARIS26SPARC" |egrep -e "17"
  P4D/SOLARIS26SPARC/2006.1/109255 (2006/10/17)

Tuesday, April 21, 2009

An abbreviated description of the Linux Boot up process

The LILO boot loader starts the kernel

The Linux kernel configured by lilo or rdev decompresses and must find and mount the root filesystem. If LILO or the kernel were not configured properly there can be a problem here.
The kernel after loading the root filesystem, starts the "init" program which may be located in /sbin/init. Reads /etc/inittab for configuration information.
/etc/inittab - init reads this file for configuration information. This file determines the starting run level and contains a line like:

/etc/rc.d/rc.sysinit - In this case this entry in "/etc/inittab" causes the script file "/etc/rc.d/rc.sysinit" to be run.
To add terminals or dial in modem lines on a system, add more lines in the /etc/inittab file, one for each terminal or dial in line similar to the following:
7:2345:respawn:/sbin/mingetty tty7

One of /etc/rc.d/rc or /etc/rc or /etc/init.d/rc is started from inittab which does initialization commands for boot at the set runlevel. This is done by running startup and shutdown scripts for various services to be run at the given run level.

/etc/rc.local is started from one of the startup scripts in the rc script file. This is where you should add custom features for your system.

getty - Init starts a separate getty (or mingetty) for each terminal for which logins are to be allowed. Getty is restarted by init after each user has logged out so new users can log in. Network logins are not done by getty but by a different deamon per way of logging in (telnet or rlogin handled by the inetd internet super daemon).

Getty outputs the welcome message in /etc/issue, reads the username and runs the login program. If the user is telnetting, the message in /etc/ is first output.

The login program reads the password and runs the shell if the username and password are correct. The shell is based on entries in the /etc/passwd file and will run at the user's privilege level rather than with root privileges.

The shell (such as bash) runs the /etc/profile script file. However in the case of a system with shadow passwords, environment strings can be set first in a file called /etc/login.defs. Also a users resources can be limited in a file called /etc/limits. The $HOME/.bash_profile script is then run, but if it is missing /etc/.profile is run.

Pertinent files:

/dev/console - A virtual console device usually called /dev/ttyn where "n" is a terminal number.
/etc/ - Contains the consoles ioctl(2) states
/var/run/utmp - A file where information on current system users is stored. The commands "w" and "who" can be used to display information in this file.
/var/log/wtmp - Has a record of all logins and logouts
/dev/initctl - Init's control fifo buffer file. Init listens on this fifo file for messages. Telinit uses this to communicate with init. The file initctl is not a script file.
/etc/passwd - Contains information about the user including the ID, name, home directory, and the path to the preferred shell program. If not using shadow passwords, this file may also contain user passwords.
In /etc/rc.d/rc0.d are kill and start scripts for various services. The kill scripts start with the letter "K" and the startup scripts start with the letter "S".

Wednesday, April 01, 2009

Sending a HTML file inline with Subject using  Sendmail command !

echo "Subject: Testing" | cat - file.html-old| /usr/lib/sendmail

Nawk to convert CSV file in HTML column/row format

/usr/bin/awk has a limit for the printf string of 398 characters.
/usr/xpg4/bin/nawk has no limit.

Nawk  to convert CSV file in HTML column/row format

nawk 'BEGIN{
print  "MIME-Version: 1.0"
print  "Content-Type: text/html"
print  "Content-Disposition: inline"
print  "<HTML>""<TABLE border="1"><TH>SA TEAM</TH><TH>Host Name</TH><TH>Host ID</TH><TH>User ID</TH><TH>Login Shell</TH><TH>GCOS Field</TH><TH>Data Source</TH><TH>Domain Name</TH><TH>Acct Status</TH><TH>Lock Type</TH>"
printf "<TR>"
printf "<TD>%s</TD>", $i
print "</TR>"
print "</TABLE></BODY></HTML>"
' file-to-convert.csv > file.html

Sending HTML Mail by way of report !!!

Sending  HTML Mail by way of report !!!

I wanted to do below :
Step 1) Convert .csv comma seperated file to .html file
Step 2) Sending the HTML file as inline mail (had to use sendmail command , mailx wont support sending mail by way of HTML inline):

Step 1) Convert .csv comma seperated file to .html file

CSV file :test.csv: (This  need to convert to .html)
EQADM,edtsdb445s4s,832caef0,gpatmon,/bin/ksh,prete Erick Whindleton
EQADM,eqzd56s5s,83cd26bd,gpatmon,/bin/ksh,rete WHINDLETON,KED_RA,none
EQADM,eqzrtshs,8343f9a5,gpatmon,/bin/ksh,hshsrick Whindleton
EQADM,ed876b4c,832cab9c,gpatmon,/bin/ksh,sjsjs Erick Whindleton
EQADM,eq234canj1,80c9b573,gpatmon,/bin/ksh,ERICK C WHINDLETON
EQADM,eqznj10-phys,83193e0b,gpatmon,/bin/ksh,Erick Whinrtsrsksksk
EQADM,eqzdsnj2-phys,8338abba,gpatmon,/bin/ksh,ERICK C WHINDLETON

For this I used awk command :

bash-2.03$ awk 'BEGIN{
print  "<HTML>""<TABLE border="1"><TH>one</TH><TH>two</TH><TH>three</TH><TH>four</TH><TH>five</TH><
printf "<TR>"
printf "<TD>%s</TD>", $i
print "</TR>"
print "</TABLE></BODY></HTML>"
' test.csv > file.html

Step 2) sending the HTML file as inline mail :


export CONTENT="index.html"
export SUBJECT="Html Format"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
) | /usr/sbin/sendmail $MAILTO