Documentation

File and Path

File and path functions are used to verify, return, and generate information about directories, file paths, names, and file names.

access

Description

The access() function verifies the existence of a path and/or file on the Policy Server host. path should contain a fully qualified name, starting with a forward slash character (/).

Syntax

result = access (path);

Arguments

pathRequired. String that contains the name of the path and/or file to verify

Return values

trueThe directory or file exists on the Policy Server host.
falseThe directory or file does not exist on the Policy Server host.

Example

In the example,

result = access ("/tmp/user.txt");
  • result contains true if /tmp/user.text exists on Policy Server host.
  • result contains false if /tmp/user.text does not exist on the Policy Server host and is not accessible to the superuser.

See also

logmktemp(), mktemp(), stat()

basename

Description

The basename() function returns the file name portion from the provided path. basename actually works by searching the provided string for the rightmost token. A forward slash character (/) delimits tokens. basename ignores any number of trailing slash characters.

For example, given the string /one/two/three, basename returns the rightmost token, which in this case is three.

Given the string /one/two/, basename would ignore the trailing slash and return two.

Syntax

result = basename (path);

Arguments

pathRequired. Character string containing a file path and file name.

Return values

result contains the rightmost token (that is, the file name) of the supplied character string (that is, the path name). An empty character string ("") is returned if no token is found.

Example

In this example, result contains the file name pblog.txt.

result = basename ("/var/adm/pblog.txt");

dirname

Description

The dirname() function returns the path component of path. dirname() searches the provided string for the rightmost token and returns everything but the rightmost token. Tokens are delimited with the forward slash character (/). dirname ignores all trailing slashes.

For example, given the string /one/two/three, dirname returns everything but the rightmost token. In this example, result contains /one/two/.

Given the string /one/two/three/, dirname ignores the tailing slash and result contains /one/two.

Syntax

result = dirname (path);

Arguments

path: Required. Character string that contains a path and file name

Return values

result contains the contents of path, minus the rightmost token (that is, the file name). If a token is not found, a . is returned.

Example

In the example, result contains the directory /var/adm/.

result = dirname ("/var/adm/pblog.txt");

See also

basename()

logmktemp

Description

The logmktemp() function returns a file name that is guaranteed to be unique on the log host.

This function requires a full path template. Do not save Iologs to temp directories.

Syntax

result = logmktemp (template);

Arguments

templateRequired. Character string that contains a file name template. Within template, characters forming a unique identifier replace six trailing X characters. Many, but not all, user systems require precisely six X characters, which must be the trailing characters. Five X character ss, or X character ss in the middle of a template, might work on some systems, but this behavior is not guaranteed.

Return values

result contains the generated file name. If a unique file name cannot be generated from template, then result contains a blank character string ("").

Example

In this example,

result = logmktemp ("/var/adm/iolog.XXXXXX");

result contains the file name /var/adm/iolog.XXXXXX, where XXXXXX is replaced by a unique identifier that is generated by the operating system.

See also

mktemp(), stat()

mktemp

Description

The mktemp() function returns a file name that is guaranteed to be unique on the Policy Server host.

ℹ️

Note

Not supported in Endpoint Privilege Management for Linux (EPM-L).

Syntax

result = mktemp (template);

Arguments

templateRequired. Character string that contains a file name template. Within template, characters forming a unique identifier replace six trailing X characters. Many, but not all, user systems require precisely six X characters, which must be the trailing characters. Five X character ss, or X character ss in the middle of a template, might work on some systems, but this behavior is not guaranteed

Return values

result contains the generated file name. If a unique file name cannot be generated from template, result contains a blank character string ("").

Example

In the example,

result = mktemp ("/var/adm/iologXXXXXX");

result contains the file name /var/adm/iolog.XXXXXX, where XXXXXX is replaced by a unique identifier that is generated by the operating system.

To create an I/O log in this way, the iolog variable must be set to the result of logmktemp(). For example:

iolog = logmktemp("/var/adm/iolog.XXXXXX");

See also

logmktemp(), stat()

stat

Description

The stat() function returns general information, from the operating system, about the requested file or directory on the policy server host. result contains an empty list (that is, with length equal to 0) if the specified file or directory is not found. The length() function can be used to determine whether result is empty.

ℹ️

Note

Not supported in Endpoint Privilege Management for Linux (EPM-L).

Syntax

result = stat (path);

Arguments

path Required. Character string containing a path and/or file name.

Return values

result is a list that contains file and/or directory information. Each element in the list contains a different piece of information, as shown below. Each list element is a character string. An empty list is returned (that is, with list length equal to 0) if the specified file or directory does not exist. If result is empty, then the specified path or file was not found.

result elements:

  • result [0] = file size
  • result [1] = file owner
  • result [2] = file group
  • result [3] = file permissions
  • result [4] = file access time
  • result [5] = file creation time
  • result [6] = file modification time
  • result [7] = file access date
  • result [8] = file creation date
  • result [9] = file modification date
  • result [10] = file access time in seconds
  • result [11] = file creation time in seconds
  • result [12] = file modification time in seconds
  • result [13] = inode number
  • result [14] = device number

Example

result = stat ("/etc");

In the example, result might contain the following elements:

result [0] = 7144
result [1] = bin
result [2] = bin
result [3] = 755
result [4] = 101
result [5] = 101
result [6] = 101
result [7] = 1970/01/01
result [8] = 1970/01/01
result [9] = 1970/01/01
result [10] = 1
result [11] = 1
result [12] = 1
result [13] = 20
result [14] = 2

ℹ️

Note

For more information, see access and length .


©2003-2025 BeyondTrust Corporation. All Rights Reserved. Other trademarks identified on this page are owned by their respective owners. BeyondTrust is not a chartered bank or trust company, or depository institution. It is not authorized to accept deposits or trust accounts and is not licensed or regulated by any state or federal banking authority.