Platform Functionality
Execution
executableExists
Does a binary exist in the PATH?
Usage
executableExists [ --any ] binary ... [ --help ]
Does a binary exist in the PATH?
Arguments
--any- Flag. Optional. If any binary exists then return 0 (success). Otherwise, all binaries must exist.binary ...- String. Required. One or more Binaries to find in the systemPATH.--help- Flag. Optional. Display this help.
Examples
executableExists cp date aws ls mv stat || throwEnvironment "$handler" "Need basic environment to work" || return $?
executableExists --any terraform tofu || throwEnvironment "$handler" "No available infrastructure providers" || return $?
executableExists --any curl wget || throwEnvironment "$handler" "No way to download URLs easily" || return $?
Return codes
0- If all values are found (without the--anyflag), or if any binary is found with the--anyflag1- If any value is not found (without the--anyflag), or if all binaries are NOT found with the--anyflag.
Requires
throwArgument decorate __decorateExtensionEach command
runCount
Run a binary count times
Usage
runCount [ count ] [ binary ] [ args ... ]
Run a binary count times
Arguments
count- The number of times to run the binarybinary- The binary to runargs ...- Any arguments to pass to the binary each run
Return codes
0- success2-countis not an unsigned numberAny- Ifbinaryfails, the exit code is returned
bashMakeExecutable
Makes all
*.shfiles executable
Usage
bashMakeExecutable [ --find findArguments ] [ path ... ]
Makes all *.sh files executable
Arguments
--find findArguments- String. Optional. Add arguments to exclude files or paths. SPACE-delimited for multiple options.path ...- Directory. Optional. One or more paths to scan for shell files. Uses PWD if not specified.
Return codes
0- Success1- Environment error2- Argument error
Environment
- Works from the current directory
Memory
Usage
processMemoryUsage pid
Outputs value of resident memory used by a process, value is in kilobytes
Arguments
pid- Integer. Required. Process ID of running process
Examples
> processMemoryUsage 23
Sample Output
423
Return codes
0- Success2- Argument error
Usage
processVirtualMemoryAllocation [ --help ] [ pid ]
Outputs value of virtual memory allocated for a process, value is in kilobytes
Arguments
--help- Flag. Optional. Display this help.pid- Process ID of running process
Examples
processVirtualMemoryAllocation 23
Sample Output
423
Return codes
0- Success2- Argument error
CPU
cpuCount
Return integer count of CPUs on this system
Usage
cpuCount [ --handler handler ] [ --help ]
Return integer count of CPUs on this system
Writes to standard output
PositiveInteger
Arguments
--handler handler- Function. Optional. Use this error handler instead of the default error handler.--help- Flag. Optional. Display this help.
Return codes
0- Success1- Environment error2- Argument error
loadAverage
Get the load average using uptime
Usage
loadAverage [ --help ]
Get the load average using uptime
Writes to standard output
lines:Number
Arguments
--help- Flag. Optional. Display this help.
Return codes
0- Success1- Environment error2- Argument error
Requires
uptime
Services
serviceToPort
Get the port number associated with a service
Usage
serviceToPort service [ --services servicesFile ] [ --help ]
Get the port number associated with a service
Arguments
service- String. Required. A unix service typically found in/etc/services--services servicesFile- File. Optional. File like '/etc/services`.--help- Flag. Optional. Display this help.
Sample Output
Port number of associated service (integer) one per line
Return codes
1- service not found2- bad argument or invalid port0- service found and output is an integer
serviceToStandardPort
Hard-coded services for:
Usage
serviceToStandardPort [ --help ] [ service ... ]
Hard-coded services for:
- ssh -> 22
- http-> 80
- https-> 80
- postgres-> 5432
- mariadb-> 3306
- mysql-> 3306
Backup when /etc/services does not exist.
Arguments
--help- Flag. Optional. Display this help.service ...- String. Optional. A unix service typically found in/etc/services
Sample Output
Port number of associated service (integer) one per line
Return codes
1- service not found0- service found and output is an integer
Users
Usage
userHome [ pathSegment ]
The current user HOME (must exist) No directories should be created by calling this, nor should any assumptions be made about the ability to read or write files in this directory.
Arguments
pathSegment- String. Optional. Add these path segments to the HOME directory returned. Does not create them.
Return codes
1- Issue withbuildEnvironmentGet HOMEor $HOME is not a directory (say, it's a file)0- Home directory exists.
Usage
userRecord index [ user ] [ database ]
Look user up, output a single user database record.
Writes to standard output
String. Associated record with index and user.
Arguments
index- PositiveInteger. Required. Index (1-based) of field to select.user- String. Optional. User name to look up. Useswhoamiif not supplied.database- File. Optional. User name database file to examine. Uses/etc/passwdif not supplied.
Return codes
0- Success1- Environment error2- Argument error
Requires
grep cut returnMessage printf /etc/passwd whoami
Usage
userRecordHome [ user ] [ database ]
Look user up, output user home directory
Writes to standard output
Directory. The user home directory.
Arguments
user- String. Optional. User name to look up. Useswhoamiif not supplied.database- File. Optional. User name database file to examine. Uses/etc/passwdif not supplied.
Return codes
0- Success1- Environment error2- Argument error
Usage
userRecordName [ user ] [ database ]
Look user up, output user name
Writes to standard output
the user name
Arguments
user- String. Optional. User name to look up. Useswhoamiif not supplied.database- File. Optional. User name database file to examine. Uses/etc/passwdif not supplied.
Return codes
0- Success1- Environment error2- Argument error
Groups
Usage
groupID groupName
Convert a group name to a group ID
Writes to standard output
Integer. One line for each group name passed as an argument.
Arguments
groupName- String. Required. Group name to convert to a group ID
Return codes
0- All groups were found in the database and IDs were output successfully1- Any group is not found in the database.2- Argument errors (blank argument)
Requires
throwArgument getent cut printf usageDocument decorate grep quoteGrepPattern