[GRASS5] wrapper for awk?

Hi all,

time for another wrapper...

On Mon, Mar 05, 2001 at 05:31:43PM +0100, mlennert@club.worldonline.be wrote:

> grass2fig needs:
> #!/bin/awk -f

On Debian Linux it is here: /usr/bin/awk...

How can we implement an awk wrapper?

Markus

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

Option 1: check for awk in configure.in, and
update the script file accordingly.

Option 2:
------------------------------------------------
#!/bin/sh
exec awk -f program.awk file ...
------------------------------------------------

where program.awk is your file without the line,

#!/path/to/awk -f

If the processing gets really complex, perhaps perl
might be a better choice.

Markus Neteler wrote:

Hi all,

time for another wrapper...

On Mon, Mar 05, 2001 at 05:31:43PM +0100, mlennert@club.worldonline.be wrote:

grass2fig needs:
#!/bin/awk -f

On Debian Linux it is here: /usr/bin/awk...

How can we implement an awk wrapper?

Markus

---------------------------------------- If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

--
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
| Eric B. Mitchell mailto:emitchell@altaira.com |
| tel: (301) 809 - 3534 Altair Aerospace Corporation |
| tel: (800) 7 - ALTAIR 4201 Northview Dr. Suite 410 |
| fax: (301) 805 - 8122 Bowie, MD 20716 |
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
               ,___
           /"\ / o=\ /"""---===/
          / \_/ \__/ ---===/
          | //\ || /""TT""/ //\ || ||""\
          | // \ || || // \ || ||__/
          | //--==\ |L--/ || //--==\ || || "=,
           \ ---===/
            \____---===/

---------------------------------------- If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

On Mon, Mar 05, 2001 at 07:24:14AM -0500, Eric Mitchell wrote:

Option 1: check for awk in configure.in, and
update the script file accordingly.

Option 2:
------------------------------------------------
#!/bin/sh
exec awk -f program.awk file ...
------------------------------------------------

where program.awk is your file without the line,

Option 3 (still only one file):
something like:

#!/bin/sh
awk --source='
/some/ { x = 1}
/awk/ { x = 1}
/source/ { x = 1}
' $1

(don't know whether only gawk has option --source

Jan

--
Jan-Oliver Wagner http://intevation.de/~jan/

Intevation GmbH http://intevation.de/
FreeGIS http://freegis.org/

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

On Mon, Mar 05, 2001 at 07:51:53PM +0100, Jan-Oliver Wagner wrote:

On Mon, Mar 05, 2001 at 07:24:14AM -0500, Eric Mitchell wrote:
> Option 1: check for awk in configure.in, and
> update the script file accordingly.

Here we have the problem with people using GRASS from
precompiled binaries.

> Option 2:
> ------------------------------------------------
> #!/bin/sh
> exec awk -f program.awk file ...
> ------------------------------------------------
>
> where program.awk is your file without the line,

Option 3 (still only one file):
something like:

#!/bin/sh
awk --source='
/some/ { x = 1}
/awk/ { x = 1}
/source/ { x = 1}
' $1

(don't know whether only gawk has option --source

Jan

I have just checked SUN's awk which offers:

awk
awk: Usage: awk [-Fc] [-f source | 'cmds'] [files]

I have applied your suggestion, Jan, and renamed to "gawk".

Moritz, could you try?

cvs up src/scripts/contrib/v.xfig

v.out.xfig
v.in.xfig

Maybe "gawk" is a requirement which can't be fulfilled everywhere,
then we should consider option 2.

Thanks for your suggestions,

Markus

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

Hi Markus

Markus Neteler wrote - slightly rearranged:

Maybe "gawk" is a requirement which can't be fulfilled everywhere,
then we should consider option 2.

Yes, some machines do not install gawk by default, one being SGI.

However,

I have just checked SUN's awk which offers:

awk
awk: Usage: awk [-Fc] [-f source | 'cmds'] [files]

                                     ^^^^^^
This is also the case on SGI so why can't we use awk? From the
fig2grass script we have the following

gawk --source='

function formerr() {
    printf "*** WRONG FIG 3.2 FORMAT ! ***\n"
    exit 1
}
<skip>
' $1 $2

So why can't we do the following?

awk '

function formerr() {
    printf "*** WRONG FIG 3.2 FORMAT ! ***\n"
    exit 1
}
<skip>
' $1 $2

If this does not work, then the only option is the second one. That is,
store the awk script in a separate file and have fig2grass call

awk -f fig2grass.awk

or something like that.

Just my 2 cents worth.

--
Sincerely,

Jazzman (a.k.a. Justin Hickey) e-mail: jhickey@hpcc.nectec.or.th
High Performance Computing Center
National Electronics and Computer Technology Center (NECTEC)
Bangkok, Thailand

People who think they know everything are very irritating to those
of us who do. ---Anonymous

Jazz and Trek Rule!!!

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

On Wed, Mar 07, 2001 at 09:59:18AM +0700, Justin Hickey wrote:

Hi Markus

Markus Neteler wrote - slightly rearranged:
> Maybe "gawk" is a requirement which can't be fulfilled everywhere,
> then we should consider option 2.

Yes, some machines do not install gawk by default, one being SGI.

However,

> I have just checked SUN's awk which offers:
>
> awk
> awk: Usage: awk [-Fc] [-f source | 'cmds'] [files]
                                     ^^^^^^
This is also the case on SGI so why can't we use awk? From the
fig2grass script we have the following

gawk --source='

function formerr() {
    printf "*** WRONG FIG 3.2 FORMAT ! ***\n"
    exit 1
}
<skip>
' $1 $2

So why can't we do the following?

awk '

function formerr() {
    printf "*** WRONG FIG 3.2 FORMAT ! ***\n"
    exit 1
}
<skip>
' $1 $2

You are right. Why not using this "simple" method :slight_smile:
Works on Linux... updated in CVS.

Thanks, Justin!

Markus

If this does not work, then the only option is the second one. That is,
store the awk script in a separate file and have fig2grass call

awk -f fig2grass.awk

or something like that.

Just my 2 cents worth.

--
Sincerely,

Jazzman (a.k.a. Justin Hickey) e-mail: jhickey@hpcc.nectec.or.th
High Performance Computing Center
National Electronics and Computer Technology Center (NECTEC)
Bangkok, Thailand

People who think they know everything are very irritating to those
of us who do. ---Anonymous

Jazz and Trek Rule!!!

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

--
Markus Neteler * University of Hannover
Institute of Physical Geography and Landscape Ecology
Schneiderberg 50 * D-30167 Hannover * Germany
Tel: ++49-(0)511-762-4494 Fax: -3984

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'