Important This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent 22.1 for BMC Helix Operations Management.

remove()


Remove a file from the file system.

Syntax

remove(filename)

Parameter

Parameter

Definition

filename

name and path of the file to be removed from the file system

Description

The remove() function:

  • removes a specified file, filename, from the file system The full path of the file must be included in the filenameparameter.
  • returns 1 if the file was successfully removed from the file system and returns 0 if the file could not be removed from the file system
  • could be unsuccessful for various reasons, including insufficient file permissions or an invalid filename

Example

The following example uses the file() function to verify the existence of a file, and then removes the file using theremove() function. If the file exists but cannot be removed, a message is returned stating that the file properties and user permissions should be checked:

file_name="D:\\temp_data.txt";
if (file(file_name)) {
print("\nFile (".file_name.") exists!\n");
if (remove(file_name)) {
print("\nFile (".file_name.") removed!\n");
} else {
print("\nFile (".file_name.") could not be removed!\n\n".
"Check file properties and user permissions!");
}
} else {
print("\nFile (".file_name.") does not exist!\n");
}