AWK unable to parse


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting AWK unable to parse
# 8  
Old 04-22-2008
To prevent this kind of problem due to missing exit statement, when calling sqlplus redirect stdin to null device.

For example, in the awk program :
Code:
   sql_cmde = "sqlplus -s edfrgv/erfcdf @" sql_file " </dev/null";

Jean-Pierre.
# 9  
Old 04-24-2008
I have another problem with this script which is doing what it is suppose to do but now the problem is with AWK which is unable to read input line more than 3000 bytes.

The error I am getting from AWK is
Quote:
Input Line greater than 3000 bytes
Is this a restriction in awk that it cannot read input line which is greater than 3000 bytes?

Please advise.
# 10  
Old 04-24-2008
In the logic of your awk program, there is no need to read the output of sqlplus command as you print it only, hust execute the command.
In that case, the awk restriction doesn't matter
Code:
dir=$PWD
cd $ORACLE_HOME

awk '
BEGIN {
   sql_file = "/tmp/sqlplus_from_awk.sql";
   sql_cmde = "sqlplus -s edfrgv/erfcdf @" sql_file;
}
substr($0, 17, 3) == "ABC"  && substr($0, 52, 8) == "00000000" {
   tr      = substr($0, 20, 10);
   ap      = substr($0, 30, 2);
   ver     = substr($0, 32, 2);
   irver   = substr($0, 34, 2);
   recdate = substr($0, 36, 8);
   logdate = substr($0, 44, 8);
   printf("exec abc_ert(%s, %s, %s, %s, %s, %s);\n",
          $tr , $ap, $ver, $irver, $recdate, $logdate) > sql_file;
   close(sql_file);
   system(sql_cmde)
   next;
}
1
' $dir/ert.dat > $dir/fff.dat

cd -

Jean-Pierre.
# 11  
Old 04-24-2008
Aigles,
The problem is not writing or reading the input line which matches the pattern criteria. Some of the lines in the file is greater than 3000 bytes (characters). AWK is unable to read these lines and provides error before it could even read the line to check for the pattern.

Is it possbile to set max of the input line i.e $0 ?

Thanks,
# 12  
Old 04-24-2008
You need only the first 60 chars of the input file, so you can truncate the inputfile for awk :
Code:
dir=$PWD
cd $ORACLE_HOME

cut -c1-100 $dir/ert.dat | \
awk '
BEGIN {
   sql_file = "/tmp/sqlplus_from_awk.sql";
   sql_cmde = "sqlplus -s edfrgv/erfcdf @" sql_file;
}
substr($0, 17, 3) == "ABC"  && substr($0, 52, 8) == "00000000" {
   tr      = substr($0, 20, 10);
   ap      = substr($0, 30, 2);
   ver     = substr($0, 32, 2);
   irver   = substr($0, 34, 2);
   recdate = substr($0, 36, 8);
   logdate = substr($0, 44, 8);
   printf("exec abc_ert(%s, %s, %s, %s, %s, %s);\n",
          $tr , $ap, $ver, $irver, $recdate, $logdate) > sql_file;
   close(sql_file)
   sql_cmde | getline sql_val
   close(sql_cmde)
   printf ("%s\n", $sql_val);
   next;
}
1
'  > $dir/fff.dat

cd -

Jean-Pierre.
# 13  
Old 04-24-2008
Aigles,
I want the content of new file to be same as original file. What I want is to replace the text (for the line having RT3 content) at position at 2651 by the value being passed by Oracle Stored procedure. If the line which is not RT3 is found then awk has to re-write the line as it is to new file.

The problem is that this line which is not RT3 some times has more than 3000 bytes of data and awk is unable to parse it.

I hope i have made myself clear.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using awk to Parse File

Hi all, I have a file that contains a good hundred of these job definitions below: Job Name Last Start Last End ST Run Pri/Xit ________________________________________________________________ ____________________... (7 Replies)
Discussion started by: atticuss
7 Replies

2. Shell Programming and Scripting

awk to parse df output

Output of the below code includes unmatched date.Please correct it df -k|awk '$4>50 {print $1, "\t"$4,"\t" $7}' It gives output less than 50% also. (5 Replies)
Discussion started by: vinil
5 Replies

3. Shell Programming and Scripting

Parse a file using awk

Hi Experts, I am trying to parse the following file; FILEA a|b|c|c|c|c a|b|d|d|d|d e|f|a|a|a|a e|f|b|b|b|boutput expected: a<TAB>b <TAB><TAB>c<TAB>c<TAB>c<TAB>c<TAB> <TAB><TAB>d<TAB>d<TAB>d<TAB>d<TAB> e<TAB>f <TAB><TAB>a<TAB>a<TAB>a<TAB>a<TAB> <TAB><TAB>b<TAB>b<TAB>b<TAB>b<TAB>*... (7 Replies)
Discussion started by: rajangupta2387
7 Replies

4. Shell Programming and Scripting

Parse input -AWK

Input File Defined configuration: cfg: CLL_DCC_Fabric_A BTS00P21; BAU_AP00P01QC; BAU_LGSCNJP02; BAU_TS00P20; BAU_DSMSM14; BAU_HT00P02; BAU_DSMSM13; BAU_HT00P01; cfg: CX0014_list BAU_TS00P20; BAU_NYP_PRODIAD1_CJ;... (5 Replies)
Discussion started by: greycells
5 Replies

5. Shell Programming and Scripting

Parse a file with awk?

Hi guys (and gals). I need some help. I'm running an IVR purely on Asterisk where I capture the DTMFs. After pulsing each DTMF I have Asterisk write to a file with whatever was dialed (mostly used for record-keeping) and at the end of the survey I write all variables in a single line to a... (2 Replies)
Discussion started by: tulf210
2 Replies

6. Shell Programming and Scripting

parse xm entry with awk/sed

Hi folks, I have XML files with the following sections (section occurs once per file) in them: <AuthorList CompleteYN="Y"> <Author ValidYN="Y"> <LastName>Bernal</LastName> <ForeName>Federico</ForeName> ... (3 Replies)
Discussion started by: euval
3 Replies

7. Shell Programming and Scripting

AWK: Parse lvdisplay

Hi, I would like to parse the next output of an lvdisplay -v using awk: --- Logical volumes --- LV Name /dev/vg01/lvol3 VG Name /dev/vg01 LV Permission read/write LV Status available/syncd Mirror copies ... (2 Replies)
Discussion started by: RuBiCK
2 Replies

8. Shell Programming and Scripting

Parse file using awk and work in awk output

hi guys, i want to parse a file using public function, the file contain raw data in the below format i want to get the output like this to load it to Oracle DB MARWA1,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 MARWA2,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 this the file raw format: Number of... (6 Replies)
Discussion started by: dagigg
6 Replies

9. UNIX for Dummies Questions & Answers

awk to parse a directory name?

Hi, I have a directory file name: /auto/space/user/jen/CED/CED_01MZ/visit1/DCE_2eco/016/echo1 I would like to just get the following outputs into variables such that: variable1 = /auto/space/user/jen/CED/CED_01MZ/visit1/ and variable2 = DCE_2eco/016/echo1 I've tried it with... (2 Replies)
Discussion started by: nixjennings
2 Replies

10. UNIX for Dummies Questions & Answers

parse string with awk

Hi Guys, I spend half a day getting this to work with no luck, perhaps you guys can help.. I have a string from a file looking like this: module::name=test::type=generic_data::exec=snmpget.......::desc=A Little Test::interval=300 what I would like to split it, so I get a value for each... (3 Replies)
Discussion started by: hyber
3 Replies
Login or Register to Ask a Question