Need Nawk for Linux or redesign of script 
Author Message
 Need Nawk for Linux or redesign of script

I have a Bourne-shell script I'm trying to run on a Red Hat Linux 5.1
machine. The script uses NAWK which I don't seem to be able to
find on the machine. To me there seems to be 2 options.

1) Install NAWK. Is this possible? Where can I find it and how
do I install it? (I have root-permission).

2) Rewrite the part of the script which uses NAWK (reason for
posting to AWK-group). The routine fetches configuration data
from another file and inserts the data into HTML-pieces of code.
The config-data repeats a numer of times and all ocurrences
holds sitestring, basestring,pagestring,namestring and urlstring.
The result is a chain of HTML-pieces with each set of those
strings being inserted in the code.
Any pros out there that can give a suggestion for a redesign?
====================
nawk '
BEGIN{FS="\t"}
/^# site/{sitestring=$NF}
/^# base/{basestring=$NF}
/^# page/{pagestring=$NF}
/^name/{namestring=$NF}
/^url/{urlstring=$NF}
{
    if ( urlstring != "" ) {
    print "<!--
############################################################# -->"
    print "<hr>"
    print "<FONT ###sitefont###><b><a href=\""basestring"\">"sitestring"</a>

Quote:
> <a href=\""urlstring"\">"pagestring"</a></b></FONT>"

    print "<p>"
    print "<FONT SIZE=###articlelinksize### ###articlehreftags###>"
    print "<pluck name="namestring" limit=1>(Last change for this site:
_updated_ CET)</pluck>"
    print "<p>"

    print "<a href=\"url\" ###articleurloptions###>- title</a><br>"
    print "</pluck>"
    print "</FONT>"
    sitestring=basestring=pagestring=namestring=urlstring=""
    }
Quote:
}

END{}
' $CONFIG/$1/$1conf_spec > $CONFIG/$1/$1spechtml
====================

Boerge



Sat, 14 Feb 2004 21:57:47 GMT  
 Need Nawk for Linux or redesign of script

Quote:

> I have a Bourne-shell script I'm trying to run on a Red Hat Linux 5.1
> machine. The script uses NAWK which I don't seem to be able to
> find on the machine. To me there seems to be 2 options.

> 1) Install NAWK. Is this possible? Where can I find it and how
> do I install it? (I have root-permission).

> 2) Rewrite the part of the script which uses NAWK (reason for
> posting to AWK-group). The routine fetches configuration data
> from another file and inserts the data into HTML-pieces of code.
> The config-data repeats a numer of times and all ocurrences
> holds sitestring, basestring,pagestring,namestring and urlstring.
> The result is a chain of HTML-pieces with each set of those
> strings being inserted in the code.
> Any pros out there that can give a suggestion for a redesign?

I suspect you can simply try to use gawk.  On the gawk (as far as I
remember) knows everything and even more than nawk knows.  Looking at
the code I don't see anything which could not be used with gawk.  But I
am no guru.  Try it!

Attila



Sat, 14 Feb 2004 22:03:49 GMT  
 Need Nawk for Linux or redesign of script

Quote:

> I have a Bourne-shell script I'm trying to run on a Red Hat Linux 5.1
> machine. The script uses NAWK which I don't seem to be able to
> find on the machine. To me there seems to be 2 options.

> 1) Install NAWK. Is this possible? Where can I find it and how
> do I install it? (I have root-permission).

> 2) Rewrite the part of the script which uses NAWK (reason for
> posting to AWK-group). The routine fetches configuration data
> from another file and inserts the data into HTML-pieces of code.
> The config-data repeats a numer of times and all ocurrences
> holds sitestring, basestring,pagestring,namestring and urlstring.
> The result is a chain of HTML-pieces with each set of those
> strings being inserted in the code.
> Any pros out there that can give a suggestion for a redesign?
> ====================
> nawk '
> BEGIN{FS="\t"}
> /^# site/{sitestring=$NF}
> /^# base/{basestring=$NF}
> /^# page/{pagestring=$NF}
> /^name/{namestring=$NF}
> /^url/{urlstring=$NF}
> {
>     if ( urlstring != "" ) {
>     print "<!--
> ############################################################# -->"
>     print "<hr>"
>     print "<FONT ###sitefont###><b><a href=\""basestring"\">"sitestring"</a>
> > <a href=\""urlstring"\">"pagestring"</a></b></FONT>"
>     print "<p>"
>     print "<FONT SIZE=###articlelinksize### ###articlehreftags###>"
>     print "<pluck name="namestring" limit=1>(Last change for this site:
> _updated_ CET)</pluck>"
>     print "<p>"

>     print "<a href=\"url\" ###articleurloptions###>- title</a><br>"
>     print "</pluck>"
>     print "</FONT>"
>     sitestring=basestring=pagestring=namestring=urlstring=""
>     }
> }
> END{}
> ' $CONFIG/$1/$1conf_spec > $CONFIG/$1/$1spechtml
> ====================

> Boerge

You might try mawk.  It is compatable with nawk and, as far as I know,
is available on Red Hat distributions.  You should only need to change
all references to nawk to mawk.

Michael Witkowski



Sat, 14 Feb 2004 23:26:22 GMT  
 Need Nawk for Linux or redesign of script

Quote:

> I have a Bourne-shell script I'm trying to run on a Red Hat Linux 5.1
> machine. The script uses NAWK which I don't seem to be able to
> find on the machine. To me there seems to be 2 options.

> 1) Install NAWK. Is this possible? Where can I find it and how
> do I install it? (I have root-permission).

> 2) Rewrite the part of the script which uses NAWK (reason for

Others have mentioned that there seems to be no code there that gnu awk
(gawk) won't understand, and since on redhat boxes awk = gawk.  Then
this little script should convert the script for you:

awk 'NR == 1 {print $0"\nAWK=/bin/awk";next}
/nawk/ {gsub (/nawk/,"$AWK");print;next} {print}' old_script  >tmp.script

Then rename tmp.script as needed.

This will provide you with a variable you can set to allow the
script to run on different platforms.



Sun, 15 Feb 2004 22:23:27 GMT  
 Need Nawk for Linux or redesign of script
....

Quote:
> ... You should only need to change all references to nawk to mawk.

Or just add a symlink named nawk pointing to mawk in a directory in the
PATH.


Mon, 16 Feb 2004 05:22:57 GMT  
 Need Nawk for Linux or redesign of script

Quote:

> ....
> > ... You should only need to change all references to nawk to mawk.

> Or just add a symlink named nawk pointing to mawk in a directory in
the
> PATH.

Even better add a symlink named nawk pointing to awk (which is gawk on
most Linux systems, at least it is on the ones that I use) ...

HTH
--
Peter S Tillier
peter dot tillier at btinternet dot com
To reply direct to me please use the above address
not the "Reply To" which activates a spam trap.



Mon, 16 Feb 2004 05:27:28 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. nawk script outputs input against my will

2. NAWK as cgi-bin script

3. Linux and Python scripts, help needed

4. Need help with nawk word sorter.

5. I need NAWK information (in spanish)

6. Need help on error in nawk.

7. Need help nawk'in out aliases!

8. Need to replace Bash script with TCL script

9. Need example of working tcl/tk script used as cgi-bin script

10. What about redesigning Smalltalk?

11. Inspector should be redesigned

12. C-FFI: GC questions, wchar_t, Melange redesign

 

 
Powered by phpBB® Forum Software