Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The while loop

Status
Not open for further replies.

frangac

Technical User
Feb 8, 2004
163
ZA
Hi All, PHV

Below is my script that reads the .ini file and if the start time is 12:00 is should them activate
the instance which it does but due to the data base allready marked as active , it returns a "MESG"
But when the next instance (conductor_DCAPS_E10_12) is read it does the system command system("Instance ACTIVATE " $1 ">" VOL) but it does not enter the while loop. It should also read Text: conductor_TAS_Chain_16 is marked allready as active in the data base

Strange enough if the first instance start time is not 12:00 then the second instance will produce
a "MESG"

Please help


FILE.ini
=========
NAME START END
---- ----- ---
conductor_TAS_Chain_16 11:00 12:00
conductor_DCAPS_E10_12 12:00 13:00
conductor_VSAT_Chain_29 11:00 10:00


What am I not doing right
Code:
awk -F " " '{
            #"date \"+%T\""  | getline Date
            Date="12:00"
            VOL="Conductor_msg"
          
          {if($2==substr(Date,1,5)){
            print $1,"ACTIVATE"
                system("Instance ACTIVATE " $1 ">" VOL)
                    while( getline MESG < VOL > 0 )
                        if(MESG~/successfuly/){    
                              print $1,MESG                
                        }
                        else if(MESG~/Text./){ 
                                 print MESG        
                        system("send_alarm") 
                        }
                        }
            else if($3==substr(Date,1,5)){
            print $1,"DEACTIVATE"
                system("Instance DEACTIVATE " $1 ">" VOL)
                     while ( getline MESG < VOL > 0 )
                        {if(MESG~/successfuly./){
                                print $1,MESG
                        }
                        else if(MESG~/Text./){
                                print MESG;
                        system("send_alarm") 
                        }
                        }
                        }
                }
                }' FILE.ini
My Result
==========
conductor_TAS_Chain_16 ACTIVATE
Text: conductor_TAS_Chain_16 is marked allready as active in the data base

conductor_DCAPS_E10_12 ACTIVATE

FILE.ini
=========
NAME START END
---- ----- ---
conductor_TAS_Chain_16 12:00 13:00
conductor_DCAPS_E10_12 12:00 13:00
conductor_VSAT_Chain_29 11:00 10:00

Many Thanks
Chris
 
Hi All,

I think I have solved my problem , the close(VOL) was missing

Thanks
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top