bitburner-src/markdown/bitburner.ns.getrunningscript.md

1.6 KiB

Home > bitburner > NS > getRunningScript

NS.getRunningScript() method

Get general info about a running script.

Signature:

getRunningScript(filename?: FilenameOrPID, hostname?: string, ...args: ScriptArg[]): RunningScript | null;

Parameters

Parameter Type Description
filename FilenameOrPID (Optional) Optional. Filename or PID of the script.
hostname string (Optional) Hostname of target server. Optional, defaults to the server the calling script is running on.
args ScriptArg[] Arguments to specify/identify the script. Optional, when looking for scripts run without arguments.

Returns:

RunningScript | null

The info about the running script if found, and null otherwise.

Remarks

RAM cost: 0.3 GB

Running with no args returns current script. If you use a PID as the first parameter, the hostname and args parameters are unnecessary. If hostname is omitted while filename is used as the first parameter, hostname defaults to the server the calling script is running on. Remember that a script is semi-uniquely identified by both its name and its arguments. (You can run multiple copies of scripts with the same arguments, but for the purposes of functions like this that check based on filename, the filename plus arguments forms the key.)