Mombu the Programming Forum

  Mombu the Programming Forum > Programming > Executable awk script


User Name
Password
REGISTER NOW! Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Display Modes
1 16th May 11:24
mickey
External User
 
Posts: 1
Default Executable awk script



Is there a way to turn a awk script into an executable so that you do
not need to have awk installed to run it?

Thanks,

-M
  Reply With Quote
SPONSORED LINKS BY GOOGLE

 


2 16th May 11:24
gazelle
External User
 
Posts: 1
Default Executable awk script



Yes. For example, suppose you have the following AWK script:

BEGIN { print "hello, world" }

You can easily convert this to:
#include <stdio.h>
int main(void) { puts("hello, world"); }

Then you invoke your C compiler on this and derive an executable, which is
independent of the original AWK source. Quite simple, really.
  Reply With Quote
3 16th May 11:24
bill seivert
External User
 
Posts: 1
Default Executable awk script


#!/path/to/awk -f
BEGIN {
....
}
etc.

But awk still needs to be installed.

Bill Seivert
  Reply With Quote
4 16th May 11:24
ed morton
External User
 
Posts: 1
Default Executable awk script


Dig up "awkcc" or some other awk to C converter, then compile the C.

Ed.
  Reply With Quote
SPONSORED LINKS BY GOOGLE

 


5 19th August 15:26
juergen kahrs
External User
 
Posts: 1
Default Executable awk script


Many years ago, I wrote a converter for this task.
The converter takes the script and the binary interpreter.
Both are bundled together into a new script. The new script
now contains the original script and the binary interpreter
and unpacks both when executed.
  Reply With Quote
6 4th September 19:27
corey lawson
External User
 
Posts: 1
Default Executable awk script


....and the #! magic string doesn't work on Windows (but assigning .awk
file extension to gawk.exe more or less ends up with the same result).

But who in their right mind would use gawk on Windows? Well, it makes
analyzing and filtering text files (i.e., database table/view dumps)
WAYYY easier and faster than linking to them via ODBC...
  Reply With Quote
7 4th September 19:27
ted davis
External User
 
Posts: 1
Default Executable awk script


There are contexts in which it does, notably Apache CGI scripts.

I use it for many CGI scripts because it is quite useful, and more
approachable than Perl. And if crafted carefully, are very portable
between XP and Linux (the trick is to make the script file have Unix
\n instead of Windows \r\n line endings).

--
T.E.D. (tdavis@gearbox.maem.umr.edu)
SPAM filter: Messages to this address *must* contain "T.E.D."
somewhere in the body or they will be automatically rejected.
  Reply With Quote
8 4th September 19:27
bsh
External User
 
Posts: 1
Default Executable awk script


I am amused to be able to report that _distribution_ awk(1)/
nawk(1) (that is, "The One True Awk") has _always_ been a compiler,
via undocumented command line options.

For that matter, it has always been able to produce execution
traces, and so on....

The "-S -f script.awk" option sequence produces a core image
of the parsed file to another file "awk.out", which is executed
by the command line "awk -Rawk.out datafile".

However, there is a caveat: it depends on how the awk(1)
executable was originally built on your system. For additional
information, see my old post at:

http://groups.google.com/group/comp....28b7bd7217a54c

=Brian
  Reply With Quote
9 4th September 19:27
External User
 
Posts: 1
Default Executable awk script


I think you can use awka to generate standalone executables.

http://awka.sourceforge.net/

worked quite well when I still used it...

Eiso
  Reply With Quote
10 4th September 19:27
corey lawson
External User
 
Posts: 1
Default Executable awk script


Cool, I didn't know about the Apache thing. I just use gawk in Win32
from the command line, which doesn't work well with #!. Too lazy to
associate .awk with gawk.exe, too, so I usually write a .cmd script to
invoke the "gawk -f myawkscript.awk ..."

On Win32, how does Apache know where to find awk, or does it just assume
that "/usr/bin/awk" maps to "X:\Program Files\awk\awk.exe" or somesuch?
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes







Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
Also visit Ogoun the Usenet Archive
666