Documentation

Input/Output

fprintf

Description

The fprintf procedure is similar to the print procedure, except that the created formatted character string is appended to a file, rather than being displayed at the user’s terminal.

See the discussion on printf for a more detailed discussion on how to create use format command characters within the format control string.

ℹ️

Note

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

Syntax

fprintf (filename, controlstring [,expression1, …]);

Arguments

filenameRequired. Character string that contains the name of a file. A fully qualified path name, starting with a forward slash character (/).
controlstringRequired. The character string, including format command characters, that is written to filename.
expression1...Optional. Values to substitute into controlstring, based on the specified format command characters.

Return values

Because fprintf is a procedure, no return value is set.

Example

In this example,

fprintf ("/var/adm/pblog.txt", "System administrator Ids: %s %s %s", "Adm1", "Adm2", "Adm3");

the character string System administrator Ids: Adm1 Adm2 Adm3 is appended to the file /var/adm/pblog.txt.

See also

print, printf, sprintf(), syslog

input

Description

The input() function prompts the user for a single line of input. There is no default prompt. If the user attempts to enter more than a single line of input, then the excess input is ignored.

Syntax

result = input (prompt);

Arguments

prompt Required. Character string that contains the prompt displayed to the user.

Return values

result is a character string that contains the single line of input that is typed by the user.

Example

In this example, the prompt Please enter you first and last name: is displayed to the user. The resulting input is stored in result.

result = input ("Please enter your first and last name:");

ℹ️

Note

For more information, see inputnoecho.

inputnoecho

Description

The inputnoecho() function prompts the user for a single line of input. There is no default prompt. It ignores excess input if the user supplies more than one line of input.

The inputnoecho() function works like the input() function, except that the input that is typed by the user is not shown on the terminal. This function is useful when prompting the user for a password or other types of confidential information.

Syntax

result = inputnoecho (prompt);

Arguments

promptRequired. Character string containing the prompt displayed to the user.

Return values

result is a character string that contains the single line of input that is typed by the user.

Example

result = inputnoecho ("Please enter your first and last name:");

In this example, the prompt Please enter you first and last name: is displayed to the user. The resulting input is stored in result.

ℹ️

Note

For more information, see input.

print

Description

The print procedure writes one or more expressions to the user’s terminal as a single line. The line terminates with a newline character. A comma separates each argument. If an integer is supplied as an argument, then its value is automatically converted to a character string. If a list is supplied, then it prints as a series of quoted strings with the entire series between braces.

The print and printnnl procedures work in the same manner. The only difference is that print terminates the generated character string with a newline character, whereas printnnl does not.

Syntax

print (expression1 [, expression2, …]);

Arguments

expression1Required. A value that is displayed to the user.
expression2, …Optional. Additional values that are displayed to the user.

Return values

Because print is a procedure, no return value is set.

Example

In the first example,

print ("Your task request has been accepted.", "Thank you.");

writes the following to the user's terminal:

Your task request has been accepted. Thank you.

This line terminates with a newline character.

The second example,

TrustedUsers = {"JWhite", "TBrown", "SBlack"};
print ("The trusted users are:", TrustedUsers);

writes the following on the user’s terminal:

The trusted users are: {"JWhite", "TBrown", "SBlack"}

This line terminates with a newline character.

See also

fprintf, outputredirect, printf, printnnl, sprintf(), syslog

printf

Description

The printf procedure creates a character string by formatting the supplied arguments according to the formatting commands in a format control string. The resulting character string is written to the user’s terminal.

The format control string controls the generation of the character string that is written to the user’s terminal. It consists of two types of information: actual content and format command characters. The format command characters are used to insert and format the supplied arguments. The number of format command characters in the format control string must match the number of supplied arguments. In other words, if there are three formatting commands in the format control string, then three function arguments are needed. Otherwise, an error is generated.

ℹ️

Note

For more information on format command characters, see Format Commands.

Syntax

printf (controlstring [,arugment1, …]);

Arguments

controlstringRequired. Character string that contains the format control string that is used to
generate the formatted string that is returned in result.
argument1 …Optional. Character strings and/or integer values to substitute into the formatted string.

Return values

Because printf is a procedure, no return value is set.

Example

In this example,

printf ("System administrator Ids: %s %s %s\n", "JWhite", "TWhitman", "EPipes");

the following string is printed:

System administrator Ids: JWhite TWhitman EPipes

See also

fprintf, outputredirect, print, sprint(), syslog

printnnl

Description

The printnnl procedure writes one or more expressions to the user’s terminal as a single line. The line does not terminate with a new line character. A space separates each argument.

The print and printnnl procedures work in the same manner. The only difference being that print terminates the generated character string with a newline character, whereas printnnl does not.

Syntax

printnnl (expression1 [, expression2, …]);

Arguments

expression1Required. An expression that contains the information to display to the user
expression2Optional. Additional expressions to display to the user.

Return values

Because printnnl is a procedure, no return value is set.

Example

In the example,

printnnl ("Your task request has been accepted."); print ("Thank you.");

writes the following to the user's terminal:

Your task request has been accepted. Thank you.

The text that is printed by printnnl is not terminated with a newline character, so the text that is printed with print appears on the same line.

See also

fprintf, outpuredirect, print, printf, sprintf(), syslog

printvars

Description

The printvars procedure prints all user and EPM variables to the user’s terminal. This function is often useful when debugging security policy files.

Syntax

printvars();

Arguments

There are no arguments.

Return values

Because printvars is a procedure, no return value is set.

Example

printvars();

readfile

Description

The readfile() function returns the contents of a file in a character string. Any file type can be processed. The entire file is placed in a single character string. The length() function can be used to determine the length of the returned character string.

Additionally, readfile checks whether the file passed as argument is in the configuration database (/etc/pb.db), and if it is, reads the file from the database. If the file is not in the database, readfile reverts to check if the file is in the filesystem.

ℹ️

Note

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

Syntax

readfile (filename);

Arguments

filenameRequired. Character string that contains the complete path and file name of the file to read.

Return values

Character string that contains the contents of the specified file.

Example

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

If the /path/file is imported to the config database, then readfile gets the file from the config database:

# pbadmin –cfg -i /path/file

syslog

Description

The syslog procedure enables you to send diagnostic messages to the syslog facility. It creates a character string by formatting the supplied arguments according to the formatting commands in a format control string. The resulting character string is written to the system’s syslog.

The format control string controls the formation of the character string that is written to the system’s syslog facility. It consists of two types of information: actual content and format command characters. The format command characters are used to insert and format the supplied arguments. The number of format command characters in the format control string must match the number of supplied arguments. In other words, if there are three formatting commands in the format control string, then three function arguments are required. Otherwise, an error is generated.

Starting with version 7.0.0, as an alternate to the use of syslog() function in the policy, you can use the settings syslog_accept_format, syslog_reject_format, syslogsession_start_format, syslogsession_start_fail_format, and syslogsession_finished_format in the pb.settings file. These settings format syslog messages for Accept and Reject events, and the session events Start, Finish, and Start_Fail.

ℹ️

Note

For more information, see Customized syslog formatting and Format commands.

ℹ️

Note

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

Syntax

syslog (controlstring [,expression1, …]);

Arguments

controlstringRequired. Character string that contains the control string that is used to generate the formatted string that is passed to the syslog facility
expression1 …Optional. Expressions to substitute into the formatted string

Return values

Because syslog is a procedure, no return value is set.

Example

In this example,

syslog ("System administrator Ids: %s %s %s", "Adm1", "Adm2", "Adm3");

the message

System Administrator Ids: Adm1 Adm2 Adm3

is written to syslog (the syslog daemon, typically syslogd, and Endpoint Privilege Management for Unix and Linux must be configured for this to work).

See also

fprintf, print, printf, sprintf(), PowerBroker syslog setting


©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.