Include file not running using igawk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Include file not running using igawk
# 1  
Old 03-24-2017
Include file not running using igawk

Greetings.

I'm on section 2.7 Including Other Files into Your Program in "The GNU Awk User’s Guide". I am on HP-UX POSIX running GNU Awk 3.1.0

I have written Test1.awk and Test2.awk as shown here:
Code:
 $cat test1.awk
BEGIN {
    print "This is script test1.\n"
}
$cat test2.awk                                                                 
@include "/TEST/JDLONG/test1.awk"
BEGIN {
    print "This is script test2."
}
$

When I run test1.awk it runs fine:
Code:
$/usr/local/bin/igawk -f /TEST/JDLONG/test1.awk 
This is script test1.

When I run test2.awk it prints its own message but not the message
from test1.awk

Code:
$/usr/local/bin/igawk -f /TEST/JDLONG/test2.awk 
This is script test2.

Someone may point out that I fully qualified my include in test2.awk
when referencing test1.awk. When I just code it like this
Code:

 @include "test1.awk"
 BEGIN {
 print "This is script test2."
 }
 

I get this result:

Code:
$/usr/local/bin/igawk -f /TEST/JDLONG/test2.awk 
igawk:/TEST/JDLONG/test2.awk:0: cannot find "test1.awk"
This is script test2.



So at least by fully qualifying it, it is at least 'resolving'
(but someone may point out the 'correct' way to code this).
(I do not see directory called 'library' anywhere near /usr/local/bin - but perhaps it is called something else?)

Here is my AWKPATH variable:
Code:
$echo $AWKPATH
/usr/local/bin/gawk:/TEST/JDLONG



AFAIK only igawk allows you to use @include so that is why I am running that.

So..anyone have any idea's on why I am not getting the print
statement from test1.awk when I run test2.awk.

TIA




Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 03-24-2017 at 11:23 AM.. Reason: Added CODE tags.
# 2  
Old 03-24-2017
loose the quotes when including test1.awk:
Code:
@include /TEST/JDLONG/test1.awk

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 03-24-2017
Solved.

Thanks - that fixed it! (Can't see the forest for the treesSmilie)
Code:
@include /TEST/JDLONG/test1.awk
 BEGIN {
 print "This is script test2."
 }
 

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Igawk vs igawk.bat

I use GNU gawk on win32 platforms and standard cmd.exe to run cmd files containing gawk commands. If I were in a unix shell I would use igawk to process "@includes" for awk "libraries" and convert them into a gawk cmd. I know you can use cygwin bash to run igawk in win32 platforms. I was just... (0 Replies)
Discussion started by: RaceQuest
0 Replies

2. Shell Programming and Scripting

Need to include two more columns in the file using awk

Hi, I have a input file with many records as below: 1J4RR4GG0BC508200 68646 1 N M i want my output file to be like with columns included dgismdh and timestamp : Example: 1J4RR4GG0BC508200 68646 1 N M dgismdh 2012-02-21 07:22:25.98591 How to do it.can we do using awk? Pls help. (6 Replies)
Discussion started by: sonam273
6 Replies

3. Shell Programming and Scripting

How do I include the file being compared into calculation?

nawk -F, 'NR==FNR{file=FILENAME;a++;next} a{if(FILENAME~file)next;b++;} END{ for(i in a){if(a && !b){print "NEW: "i}} for(i in b){if(b)print i"\t\t"b}}' OFS=, 123.csv *.csv I need to include 123.csv into the equation for the total output currently it compares whatever is on 123.csv against... (27 Replies)
Discussion started by: llcooljatt
27 Replies

4. Shell Programming and Scripting

include file name to extracted files

I've written the script below to merge only .txt files that exist in one directory into one huge .txt file and ignore other files with other extensions. now the result is one huge .txt file with all the contents of other .txt files how can i add a File Name as a comment before each file? ... (12 Replies)
Discussion started by: miss_dodi
12 Replies

5. Programming

Cannot find include file: <sqlca.h>

All, I am getting the following error License : Got the license for Sun WorkShop Compiler C SPARC continuing.. "rlnseg_test.c", line 300: cannot find include file: <sqlca.h> "rlnseg_test.c", line 417: undefined symbol: sqlca "rlnseg_test.c", line 447: undefined symbol: sqlca... (2 Replies)
Discussion started by: thana
2 Replies

6. Shell Programming and Scripting

memory leak in igawk script

Hi, We are having igawk statement calling gawk function and processing a master file, each gawk function have rules and action. We are using associative array to keep the output of each rule and finally printing the associative array. We are seeing the memory is growing incrementally in TOP... (1 Reply)
Discussion started by: satvelucbe
1 Replies

7. Programming

Not able to compile Pro*c file due - give errors and points to /usr/include/.. file

I am trying to compile the pro*C file but gives errors. It says it encountered "std" while it was expecting ; , = ( $ $ORACLE_HOME/bin/proc tradewind/dataaccess/Blob.pcc Pro*C/C++: Release 10.2.0.3.0 - Production on Fri May 9 11:10:54 2008 Copyright (c) 1982, 2005, Oracle. All rights... (0 Replies)
Discussion started by: shafi2all
0 Replies

8. Shell Programming and Scripting

how to include header file in b-sh script

I'm new in this. In C/C++, you define variables in one header file & then simply include it in any files where those variables are referenced. I tried to include a header named DefineVars- which initializes all the globals- but when I add the line "DefineGlobals" at the begining of another... (2 Replies)
Discussion started by: bluemoon1
2 Replies

9. UNIX for Dummies Questions & Answers

rename a file to include the ip address

I am trying to pull 100 different files from 100 different servers, each file has the same name. To prevent over writing of the files i want to edit the file name to include the IP address of where it came from. Being new to Unix I have no idea how to script this.... Help.. Regards Mac (10 Replies)
Discussion started by: MrMac
10 Replies

10. Shell Programming and Scripting

How to include PDF file with spaces

I am able to include a pdf file as an attachment in an email using the following: echo "" > reports elm -s "RW100 PDF Reports" me@myemail.com < reports However, if I have a filename that contains some spaces, I'm not so lucky. I've tried: echo "" > reports but no luck. I keep getting... (1 Reply)
Discussion started by: lawadm1
1 Replies
Login or Register to Ask a Question