-
Notifications
You must be signed in to change notification settings - Fork 18
os.q
This library provides an abstraction layer to some commonly used Operating System functionality.
Currently supported:
- Windows (
w
) - Linux (
l
) - Mac OS X (
m
)
This function returns the available commands for the operating system that the kdb process is running on
Set on library initialisation with the current OS type as a symbol (e.g. l
= Linux)
The separator character for PATH-type environment variables on the current OS:
- Linux / Mac / Solaris:
:
- Windows:
;
The PATH-type environment variable to use to search for shared libraries (see so.q.md for an implementation example):
- Linux / Solaris:
LD_LIBRARY_PATH
- Mac:
DYLD_LIBRARY_PATH
- Windows:
PATH
Use this function to execute the OS functionality
q) .os.run[`pwd;::]
Running system command: "echo %cd%"
"C:\\Users\\jasra_000\\git\\kdb-common "
/ Ensure the file library is loaded
q) newFolder:.convert.hsymToString ` sv .file.getCwd[],`mkdirTest
q) .os.run[`mkdir; newFolder]
Running system command: "mkdir C:\Users\jasra_000\git\kdb-common\mkdirTest"
q)
This function returns a boolean if the specified PID is valid and exists on the current server (using the pidCheck
OS command)
This function returns the current terminal window size in 'system "c"' format - lines columns (using the terminalSize
OS command)
q).os.getTerminalSize[]
Running system command: "stty size"
"85 156"
This function returns true if the kdb process is running in an interactive session, false otherwise
q).os.isInteractiveSession[]
Running system command: "tty --quiet; echo $?"
1b
> echo '.require.init[]; .require.lib`os; .os.isInteractiveSession[]' | $QHOME/l64/q src/require.q
...
Initialised library: os
Running system command: "tty --quiet; echo $?"
0b
This function returns the process architecture as either x86
(32-bit) or x86_64
(64-bit)
q).os.getProcessArchitecture[]
`x86_64
-
mkdir
: Create a directory including any intermediate directories that do not exist -
rmdir
: Remove an empty directory -
pwd
: Print the current working directory -
rm
: Delete a non read-only file, logging what is being deleted -
rmF
: Delete any file, logging what is being deleted -
rmFolder
: Remove a folder and all its contents -
safeRmFolder
: Remove a folder only if it is empty -
ln
: Create a symbolic link -
mv
: Move a file or folder -
cpFolder
: Copy a folder and it's contents -
pidCheck
: If the specified PID is active on the current server -
sigint
: Send a SIGINT signal to the specified PID -
sigterm
: Send a SIGTERM signal to the specified PID -
sigkill
: Send a SIGKILL signal to the specified PID -
sleep
: Delay for a fixed amount of time (interval type is defined by the underlying OS command) -
tail
: Return the latest lines from a file -
procCount
: Query the number of CPU cores on the current server -
which
: Find the full path of a shell command -
ver
: Query the version string of the application -
cpuAssign
: Returns the CPU cores that the current process is assigned to -
terminalSize
: The size of the current terminal that process is running within -
isInteractive
: If the current process is running within an interactive terminal or not
Copyright (C) Sport Trades Ltd 2017 - 2020, John Keys and Jaskirat Rajasansir 2020 - 2024