Technical data

8. Documentation for Developers
The example checks whether a file exists in the current configuration directory.
If OPENVPN_1_SECRET='test' is set in the configuration file, the loop in the first run checks
for the existence of the file etc/openvpn/test.secret in the current configuration directory.
After the call two variables are defined:
<Key>_res: Result of the system call stat() (“OK”, if system call was successful, else the
error message of the system call)
<Key>_size: File size
It may for example look like this:
stat ("unix/Makefile", test)
if ("$test_res" == "OK")
then
warning "test_size = $test_size"
else
error "Error '$test_res' while trying to get size of 'unix/Makefile'"
fi
A file name passed as a string constant is subject of variable substitution (Page 300).
Search files: fgrep
If you wish to search a file via “grep”
4
you may use the fgrep command. The syntax is:
fgrep (<File name>, <RegEx>)
If the file <File name> does not exist mkfli4l will abort with a fatal error! If it is not sure
if the file exists, test this before with stat. After calling fgrep the search result is present in
an array called FGREP_MATCH_%, with its index x as usual ranging from one to FGREP_MATCH_N.
FGREP_MATCH_1 points to the whole range of the line the regular expression has matched, while
FGREP_MATCH_2 to FGREP_MATCH_N contain the n-1 th part in brackets.
A first example will illustrate the use. The file opt/etc/shells contains the line:
/bin/sh
The following code
fgrep("opt/etc/shells", "^/(.)(.*)/")
foreach v in FGREP_MATCH_%
do
warning "%v='$v'"
done
produces this output:
Warning: FGREP_MATCH_1='/bin/'
Warning: FGREP_MATCH_2='b'
Warning: FGREP_MATCH_3='in'
4
“grep” is a common command on *nix-like OSes for filtering text streams.
306