Syntax Checker Script




Hello,



I want a script which is going to check if the numbers specified in the
config file is the same for each of the types of lines in the seeding
files.



The script would read each line to check if the no of columns is correct
as proposed in a config file.



If it is not correct, out put an entire list of lines which were not
correct with line number in OUTPUT file and exit with an error.



If all the lines were correct, exit normally.



Config.ini

ROUTER,22

IF,19

QOSINTERFACE,18



Seed.csv file

QOSINTERFACE,BusPhonePrefix,BusAreaCode,BusPhoneLast4

QOSINTERFACE,BusPhonePrefix,BusAreaCode,BusPhoneLast4

IF,BusPhonePrefix,BusAreaCode,BusPhoneLast4,BusAreaCode

IF,BusPhonePrefix,BusAreaCode,BusPhoneLast4

QOSINTERFACE,BusPhonePrefix,BusAreaCode,BusPhoneLast4

ROUTER,BusPhonePrefix,BusAreaCode,BusPhoneLast4,BusAreaCode,

QOSINTERFACE,BusPhonePrefix,BusAreaCode,BusPhoneLast4,BusAreaCode

ROUTER,BusAreaCode,BusPhonePrefix,BusPhoneLast4,BusPhonePrefix,



Below is the code for this particular requirement but right now inputs
are hard coded

I want that this script read from Config.ini file.

Can anybody help me out in this?





#!/usr/bin/perl



$outcome = validateFile();

if($outcome == 1) {print("file is not proper, Please check the
file\n");}

else {print("Everything is fine in a file\n");}





sub validateFile

{

my $state=0;

$ARGV[0]=ROUTER;

$ARGV[1]=5;

my $first=$ARGV[0];

my $second=$ARGV[1];

my $line_num = '';

my $fname="seed.csv";







open(OF, $fname) or die "Can't open user database file!\n";

$. = 0;

LINE: while ($temp_line = <OF>) {



chomp $temp_line;



@array = split(/,/,$temp_line,-1);



#print "CURRENT LINE $temp_line\n";



if ($first eq $array[0])

{

#print("$first is found\n");

$arraylength=@array;

# check particular line

if($second ne $arraylength)

{

print "CURRENT LINE $temp_line\n";


$line_num = $.;

print "LINE NUMBER $line_num\n";


print("Lenght of Current Line is
$arraylength which is not matching with $second\n");

$state=1;

#last;

}



}

next LINE;



}

close($fname);

return ($state);

}





Thanks,

Nishant




The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com

Relevant Pages

  • Re: Analysis Services Command line
    ... You will see that there is a switch to supply a config file. ... variable and then have the DDL task take the script from the variable. ... I am learning to use the DTEXEC. ... >> Within an IS package there is a new task called Execute Analysis Services ...
    (microsoft.public.sqlserver.olap)
  • Re: Why not XML based configurationfiles?
    ... >>I still have yet to see your working shell script that can parse XML ... Sure one might need to parse a config file in a shell script "for ... the XML file directly or make heavy use of cfg-tool. ...
    (comp.os.linux.misc)
  • Re: Whereis Kernel? & Why Debian "KDE" freezing?
    ... > There is no config file in. ... Thats not a Script, thats the kernel. ... your KDE is unstable. ...
    (alt.linux)
  • Re: Bash/Shell scripting practices/conventions
    ... I just finished my first bigger bash script and I want to upload it to ... To check whether a command (here 'fold') is executable, ... If a config file exists at the default position, ...
    (comp.unix.shell)
  • loadtimes script
    ... Here is the script and a sample config file. ... # parts of the process the transition was between. ... TransitionFromProcessRef (VARCHAR) "%s" ...
    (comp.programming)