assistance needed to add 2 other routines to my script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting assistance needed to add 2 other routines to my script
# 1  
Old 11-19-2010
assistance needed to add 2 other routines to my script

Hello guys,

In my script, I need to add two other routines where I Manipulate the files with a 'x'

The routine looks at CLI named qip-getobjectprof that references a input file named hosts_list.txt

Then I use the CLI named qip-setobject to set the orignal name with an 'x'and move the orginal name to another IP.

All good.

Unfortunately, I also need the input file to also look in another section of the same record using another CLI named exportdnsrr
to do the same. Put an 'X' on the orginal records that are there then use another CLI enterdnsrr to move it based on the original input file.

Then of course where the option is selected Rollback to Orig. objects to do it all in reverse.

Can someone use the script I have provided and make the additions to make this all happen?

An example of the routine I want to add in the shell script:


[root@ESM1 bin]# ./exportdnsrr -f ( for filename, using the hosts_list.txt )
192.168.0.6,richie,IN,A,-1,200.200.200.1,F,,0,0,,

Then take the hostname richie and put an 'x' so it will look like richieX

then use enterdnsrr on the rollback routine to put it back

./enterdnsrr -f ( another variable since A & B are used already) to put all the changes back

Thanks

Code:
#########################################################################
#                                                                       #
# Input file to contain list of all Critical Servers with Corresponding #
# DR Servers in 2 columns eg. ip addresses only                         #
#                                                                       #
# Column 1 - Production server_1                                        #
# Column 2 - Disaster Recover dr_server_1 (failover system)             #
#                                                                       #
# 192.168.5.100 192.168.6.200                                           #
# 192.168.5.101 192.168.6.201                                           #
#                                                                       #
#                                                                       #
#########################################################################
. /opt/qip/etc/qiprc         # Source QIP Variables
. /opt/sybase/SYBASE.sh
#
# Variables Used
#
In_File="/home/ammuser/RICHARD-DR/host_list.txt"        # Input with above layout
Temp_Dir="/home/ammuser/RICHARD-DR/tmp/`date +%m_%d_%y`"    # Obect profile directory
Mod_Dir="${Temp_Dir}/modified"                 # Modified Object Profile directory
Host=1
Dns_Server="qipdrpinfs001.RICHARD.com.au" # Primary DNS Server
#
# Main Loop
#
while : {
do
clear
echo ""
#[ -f ${In_File} ] && echo "Current Input file :- ${In_File}"
[ -d ${Temp_Dir} ] && echo "Current Object Dir :- ${Temp_Dir}"
echo "==========================================================="
echo "Current Input file :- ${In_File}"
echo "Current Object Dir :- ${Temp_Dir}"
echo "==========================================================="
echo "==========================================================="
echo "(usuage) Must run as ROOT"
echo "(Must set reference qipman username and password in script"
echo ""
echo ""
echo "*********************************************************"
echo "*********************************************************"
echo "        DNS-DR Host processing - Main Menu RICHARD"
echo "*********************************************************"
echo "*********************************************************"
echo "Process DR hosts file .............a"
echo "Rollback to Orig. objects .........b"
echo "Update Primary DNS qipdrpinfs001...c"
echo "Quit...............................q"
echo "---------------------------------"
echo "Please make a selection:"
read ans
case ${ans} in
  a)
    [ -f ${In_File} ] || echo "Input file :- ${In_File} does not exist !!!"
    if [ -d ${Temp_Dir} ]
    then
    {
    echo "Destination Object Directory already Exist "
    echo "Are you sure you want to continue (y/n) ..."
    read a
        if [ "$a" = "y" ]
        then
        {
        echo "Backing up $Temp_Dir old dir ! ...."
        mv ${Temp_Dir} "${Temp_Dir}.`date +%T`" # Remove old directory
        #
        # Make Directories if does not exist
        #
        [ ! -d "${Temp_Dir}" ] && /bin/mkdir "${Temp_Dir}"
        [ ! -d "${Mod_Dir}" ] && /bin/mkdir "${Mod_Dir}"
        #
        ###################################################################
        # Validate if the object exist in QIP
        # and create QIP Object Profile files for production and DR Object
        ###################################################################
        #
        ###################################################################
        # Validate if the object exist in QIP
        # and create QIP Object Profile files for production and DR Object
        ###################################################################
        #
        echo "###########################"
        echo "Processing host file"
        cat "$In_File"
        echo "###########################"
        sleep 2
        while read a b
        do
           qip-getobjectprof -u qipman -p qipman -s QIPSYBASE -a $a -f ${Temp_Dir}/${Host}.a.txt
           qip-getobjectprof -u qipman -p qipman -s QIPSYBASE -a $b -f ${Temp_Dir}/${Host}.b.txt
           Host=`expr $Host + 1`
        done < ${In_File}
        #
        #
        cd ${Temp_Dir}
        #
        ###################################################################
        # Manipulate the files created above essentially renaming the
        # Production Object and creating an Alias for Prod Name to point
        # to Disaster Recovery Object
        ###################################################################
        #
        for i in `ls *.a.txt`
        do
                #
                # Store the Host name before we make changes to object profile
                # to later use as Alias to DR object
                #
           H_alias=`cat $i |grep ObjectName |awk -F= '{print $2}'`
                #
                # Append ObjectName with "x" to avoid name conflicts.
                #
           sed -e 's/^ObjectName.*/&x/' $i > ${Mod_Dir}/$i
                #
                # Work out corresponding file to the Changed Production Object
                #
           DR_File=`echo $i|awk -F. '{print $1".b."$3}'`
                #
                # Modify the matching DR Object files with Alias Entries
                #
           sed -e "s/^Aliases.*/& $H_alias/" $DR_File > $Mod_Dir/$DR_File
        done
                #
                # Commit changes to Database
                #
        cd $Mod_Dir
        for j in `ls`
        do
           qip-setobject -u qipman -p qipman -s QIPSYBASE -d $j
           echo "Setting $j ..."
        done
        }
        fi
     }
     else
     {
        #
        # Make Directories if does not exist
        #
        [ ! -d "${Temp-Dir}" ] && /bin/mkdir "${Temp_Dir}"
        [ ! -d "${Mod_Dir}" ] && /bin/mkdir "${Mod_Dir}"
        #
        ###################################################################
        # Validate if the object exist in QIP
        # and create QIP Object Profile files for production and DR Object
        ###################################################################
        #
        while read a b
        do
           qip-getobjectprof -u qipman -p qipman -s QIPSYBASE -a $a -f ${Temp_Dir}/${Host}.a.txt
           qip-getobjectprof -u qipman -p qipman -s QIPSYBASE -a $b -f ${Temp_Dir}/${Host}.b.txt
           Host=`expr $Host + 1`
        done < ${In_File}
        #
        #
        cd ${Temp_Dir}
        #
        ###################################################################
        # Manipulate the file s created above essentially renaming the
        # Production Object and creating an Alias for Prod Name to point
        # to Disaster Recovery Object
        ###################################################################
        #
        for i in `ls *.a.txt`
        do
                #
                # Store the Host name before we make changes to object profile
                # to later use as Alias to DR object
                #
           H_alias=`cat $i |grep ObjectName |awk -F= '{print $2}'`
                #
                # Append ObjectName with "x" to avoid name conflicts.
                #
           sed -e 's/^ObjectName.*/&x/' $i > ${Mod_Dir}/$i
                #
                # Work out corresponding file to the Changed Production Object
                #
           DR_File=`echo $i|awk -F. '{print $1".b."$3}'`
                #
                # Modify the matching DR Object files with Alias Entries
                #
           sed -e "s/^Aliases.*/& $H_alias/" $DR_File > $Mod_Dir/$DR_File
        done
                #
                # Commit changes to Database
                #
        cd $Mod_Dir
        for j in `ls`
        do
           qip-setobject -u qipman -p qipman -s QIPSYBASE -d $j
           echo "Setting $j ..."
        done
     }
     fi
     sleep 2
     ;;
   b)
          {
            #cd Temp_Dir="$dir"
            echo "Rolling back objects to Original properties ..."
            cd ${Temp_Dir}
            for x in `ls *txt`
             do

               qip-setobject -u qipman -p qipman -s QIPSYBASE -d $x 2> /dev/nul
               echo "Setting $x ..."
             done
          }
        {
          echo "Rolling back objects to Original properties ..."
          cd ${Temp_Dir}
          for x in `ls *txt`
           do
             qip-setobject -u qipman -p qipman -s QIPSYBASE -d $x 2> /dev/null
             echo "Setting $x ..."
        echo "=============================================="
        echo "Objects from $x was safely reverted back !"
        echo "=============================================="
#       sleep 3
        echo "Done !"
        sleep 3
           done
        }
     ;;
   c)
     echo "Updating DNS Server ${Dns_Server} .."
     qip-dnsupdate -u qipman -p qipman -s QIPSYBASE -n ${Dns_Server}
     echo "... done."
     echo "Press any key to continue ."
     read dummy
     ;;
   q|Q)
     exit 0
     ;;
   *)
     echo "Invalid Selection ..."
     sleep 2
     ;;
esac
done

---------- Post updated at 06:24 PM ---------- Previous update was at 11:07 AM ----------

Hi,

Is this a tough one? do you need more information?

Last edited by richsark; 11-19-2010 at 12:24 PM.. Reason: claification
# 2  
Old 11-19-2010
what have you attempted so far?
# 3  
Old 11-21-2010
HI,
Well...I cant seem to grasp where the two additional routines need to go at the same time, modifying the original script to work together.

I am not an expert, but was handed this to fix. So I am seeking someone who can incorporate this.

Thank you kindly
# 4  
Old 12-01-2010
Hi, Any luck with someone helping me?
Let me know if I can provide any more information.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Archiving assistance needed date to month

We have year folder say in a path /opt/informat/Archive a folder 2012. And in the same folder /opt/informat/Archive we have different folders month based, like 201210, 201211, 201212, this have data for each month, ie files. Now time to time i need to move the monthly folders to the main folder... (1 Reply)
Discussion started by: raghavraok
1 Replies

2. Shell Programming and Scripting

Assistance needed for pattern matching

Hi, Below are input files:- File1:- 1: ### CREATE TABLE ## 2: SOMETHING ELSE 1 3: ### CREATE TABLE ## 4: ### CREATE <spaces> 5: TABLE ### 6:SOMETHING ELSE 2 7: ## CREATE 8: <spaces> TABLE ### 9: SOMETHING ELSE 3 File2:- Similar Format... Desired 1 Output File:- (3 Replies)
Discussion started by: kishal
3 Replies

3. Shell Programming and Scripting

script assistance needed - create an archive of INI files

First and foremost - me != unix bubba. Here is the situation. We have a box with data AND settings in the same directory path. (Data files aren't in the SAME directories as settings.) I need a script that generates a tarred-up archive of only the INI files with the directory structure. We... (2 Replies)
Discussion started by: hindesite
2 Replies

4. UNIX for Advanced & Expert Users

Assistance Needed With Find/Replace in Vi

Hello All I have always had a question about find and replace in Vi. As this uses Vi, sed, and RegEx I never knew how or where to post the question but I thought I would give it a shot here. Say I have a text file filled with the following: Sue, your IP address is 192.168.1.10 which is... (4 Replies)
Discussion started by: NoSalt
4 Replies

5. Shell Programming and Scripting

Assistance needed with perl script

Ok, theres a log file containing the below. Lets call the logfile log_fantastic: 2009/03/16 21:42:45 USER: tonnabo - MAC: 0014BF2D385A - STATUS_ID: 30 - STATE: ERROR 2009/03/16 21:42:45 USER: tonnabo - MAC: 001310AC120D - STATUS_ID: 15 - STATE: OK 2009/03/16 21:42:45 USER: tonnabo - MAC:... (5 Replies)
Discussion started by: SkySmart
5 Replies

6. Shell Programming and Scripting

can we use routines of datastage in unix script

Hi all, My aim is to get the log details of datastage job using unix scipt. we know that DSjob are used to get the log details from datastage universe through the adminstrator.can we call that DSjob rountine in our unix script. Thanks in advance Regards, NimmyRaju:) (0 Replies)
Discussion started by: nimmyraju
0 Replies

7. UNIX for Dummies Questions & Answers

Yellow Book assistance needed

Has anyone worked with yellow book in a unix/linux environment? If so, could you provide me with more answers around this? (2 Replies)
Discussion started by: FL1
2 Replies

8. UNIX for Dummies Questions & Answers

Assistance needed.

the command "nawk" returns the error command cannot be found in my unix system. Is there a specific library i need to have to use this command? I tried, the whereis command and it returns nothing. if there is nothing to do, what command can i use to replace this nawk command? Appreciate some... (4 Replies)
Discussion started by: 12yearold
4 Replies

9. UNIX for Dummies Questions & Answers

NFS mount assistance needed...

Hello all - I've searched this forum, but was unable to find out the info I need. I'm trying to mount (nfs mount) a directory on another box from my Linux machine. The mount point resides on a Tru64 digital unix machine. The machine trying to do the mount is a Linux machine (redhat 8.0). ... (2 Replies)
Discussion started by: Heron
2 Replies
Login or Register to Ask a Question