Operating System - HP-UX
1752704 Members
6716 Online
108789 Solutions
New Discussion

Re: Need a script for the below actions

 
Sreer
Valued Contributor

Need a script for the below actions

Hi Gurus,

 

I need to develop a script for the below scenario.

 

My scripting skill is not so good..

I need to have a script for the below setup.

 

1 - check if /home/nullecte is defined in local /etc/auto_home

      If no, send an alert ("/home/nullecte not defined on host ...") by email to :
   sree@abc.com
  and then, exit script

 2 - check availability of node "nullecte"
  If no, send an alert ("/home/nullecte not available from host ...") by email to :
   sree@abc.com
  and then, exit script
  
 3 - check if there are differencies between
  /etc/auto_home and /home/nullecte/TechD/ref/auto_home
  
  If no -> nothing to do
  If yes -> replace local /etc/auto_home by ref (/home/nullecte/TechD/ref/auto_home)

 4 - check if there are differencies between
  /etc/auto_home and /home/nullecte/TechD/ref/auto_home
  
  If yes -> send an alert ("auto_home inconsistency on host ...") by email to :
   sree@abc.com

could you please help me to get a script for this?

 

Many thanks in advance.

 

Rgds

Sree

3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: Need a script for the below actions


@Sreer wrote:

I need to develop a script for the below scenario.

 

My scripting skill is not so good..

I need to have a script for the below setup.

 

1 - check if /home/nullecte is defined in local /etc/auto_home

      If no, send an alert ("/home/nullecte not defined on host ...") by email to :
   sree@abc.com
  and then, exit script

 2 - check availability of node "nullecte"
  If no, send an alert ("/home/nullecte not available from host ...") by email to :
   sree@abc.com
  and then, exit script
  
 3 - check if there are differencies between
  /etc/auto_home and /home/nullecte/TechD/ref/auto_home
  
  If no -> nothing to do
  If yes -> replace local /etc/auto_home by ref (/home/nullecte/TechD/ref/auto_home)

 4 - check if there are differencies between
  /etc/auto_home and /home/nullecte/TechD/ref/auto_home
  
  If yes -> send an alert ("auto_home inconsistency on host ...") by email to :
   sree@abc.com

could you please help me to get a script for this?


Hi:

 

Help or write?  The best way to learn how to do something is to try!   Here's some pointers, comment by comment:

 

#1 Consider 'grep'.  For example, 'grep -q nullecte /etc/auto_home' will return a zero exit status if a match is found.

 

#2 Define "availability".  Do you mean ping-able?  Do you mean a particular process is running?

 

#3 'diff' is your friend.  Read its manpages.  As for replacements, look at 'sed', in the general form of 'sed -e '/this/that/' infile > outfile'.  By the way, what do you mean by " ref (/home/nullecte/TechD/ref/auto_home)"?

 

#4 'diff' again

 

As for sending mail, simple alerts can be composed thusly:

 

# echo "I want help" | mailx -s "HELP!" sreer

 

...where "I want help" is the body of the message and "HELP!" is the subject and you are the recipient.

 

If everything you want to say is in the sublect line, do:

 

# mailx -s "HELP HELP HELP" sreer < /dev/null

 

Regards!

 

...JRF...

Sreer
Valued Contributor

Re: Need a script for the below actions

Hi James,

 

Thanks for your extreme help...

 

Iam trying to make it up with your help...

 

Will let you know if it win/Loss :-)

 

Rgds

Sree

James R. Ferguson
Acclaimed Contributor

Re: Need a script for the below actions


@Sreer wrote:

Iam trying to make it up with your help...

 

Will let you know if it win/Loss :-)


Hi (again) Sreer:

 

You win as long as you try!  When you are stuck, post what you have tried.

 

Regards!

 

...JRF...