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