gawk
on OpenVMS ¶Command-line parsing and quoting conventions are significantly different
on OpenVMS, so examples in this Web page or from other sources often need minor
changes. They are minor though, and all awk
programs
should run correctly.
Here are a couple of trivial tests:
$ gawk -- "BEGIN {print ""Hello, World!""}" $ gawk -"W" version ! could also be -"W version" or "-W version"
Note that uppercase and mixed-case text must be quoted.
The OpenVMS port of gawk
includes a DCL
-style interface in addition
to the original shell-style interface (see the help entry for details).
One side effect of dual command-line parsing is that if there is only a
single parameter (as in the quoted program string), the command
becomes ambiguous. To work around this, the normally optional --
flag is required to force Unix-style parsing rather than DCL
parsing.
If any other dash-type options (or multiple parameters such as data files to
process) are present, there is no ambiguity and -- can be omitted.
The exit
value is a Unix-style value and is encoded into an OpenVMS exit
status value when the program exits.
The OpenVMS severity bits will be set based on the exit
value.
A failure is indicated by 1, and OpenVMS sets the ERROR
status.
A fatal error is indicated by 2, and OpenVMS sets the FATAL
status.
All other values will have the SUCCESS
status. The exit value is
encoded to comply with OpenVMS coding standards and will have the
C_FACILITY_NO
of 0x350000
with the constant 0xA000
added to the number shifted over by 3 bits to make room for the severity codes.
To extract the actual gawk
exit code from the OpenVMS status, use:
unix_status = (vms_status .and. %x7f8) / 8
A C program that uses exec()
to call gawk
will get the original
Unix-style exit value.
OpenVMS reports time values in GMT unless one of the SYS$TIMEZONE_RULE
or TZ
logical names is set.
The default search path, when looking for awk
program files specified
by the -f option, is "SYS$DISK:[],AWK_LIBRARY:"
. The logical
name AWKPATH
can be used to override this default. The format
of AWKPATH
is a comma-separated list of directory specifications.
When defining it, the value should be quoted so that it retains a single
translation and not a multitranslation RMS
searchlist.
This restriction also applies to running gawk
under GNV,
as redirection is always to a DCL command.
If you are redirecting data to an OpenVMS command or utility, the current
implementation requires setting up an OpenVMS foreign command that runs
a command file before invoking gawk
.
(This restriction may be removed in a future release of gawk
on OpenVMS.)
Without this command file, the input data will also appear prepended to the output data.
This also allows simulating POSIX commands that are not found on OpenVMS or the use of GNV utilities.
The example below is for gawk
redirecting data to the OpenVMS
sort
command.
$ sort = "@device:[dir]vms_gawk_sort.com"
The command file needs to be of the format in the example below.
The first line inhibits the passed input data from also showing up in the output. It must be in the format in the example.
The next line creates a foreign command that overrides the outer foreign command which prevents an infinite recursion of command files.
The next to the last command redirects sys$input
to be
sys$command
, in order to pick up the data that is being redirected
to the command.
The last line runs the actual command. It must be the last command as the data
redirected from gawk
will be read when the command file ends.
$!'f$verify(0,0)' $ sort := sort $ define/user sys$input sys$command: $ sort sys$input: sys$output: