2019-03-03 04:08:54 +01:00
|
|
|
isRunning() Netscript Function
|
|
|
|
==============================
|
|
|
|
|
2021-04-21 14:20:26 +02:00
|
|
|
.. js:function:: isRunning(filename[, hostname=current hostname[, args...]])
|
2019-03-03 04:08:54 +01:00
|
|
|
|
|
|
|
:RAM cost: 0.1 GB
|
2021-03-12 08:51:56 +01:00
|
|
|
:param string filename: Filename of script to check. case-sensitive.
|
2021-04-21 14:20:26 +02:00
|
|
|
:param string hostname: Hostname of target server. Defaults to current server
|
2021-03-12 08:51:56 +01:00
|
|
|
:param args...: Arguments to specify/identify which scripts to search for
|
|
|
|
:returns: ``true`` if that script with those args is running on that server.
|
|
|
|
|
|
|
|
.. note::
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
Remember that a script is uniquely identified by both its name and its arguments.
|
2019-03-03 04:08:54 +01:00
|
|
|
|
|
|
|
**Examples:**
|
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
In this first example below, the function call will return true if there is
|
|
|
|
a script named ``foo.script`` with no arguments running on the
|
|
|
|
``foodnstuff`` server, and false otherwise:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
isRunning("foo.script", "foodnstuff");
|
|
|
|
|
|
|
|
In this second example below, the function call will return true if there is
|
|
|
|
a script named ``foo.script`` with no arguments running on the current
|
|
|
|
server, and false otherwise:
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
.. code-block:: javascript
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
isRunning("foo.script", getHostname());
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
In this next example below, the function call will return true if there is a
|
|
|
|
script named ``foo.script`` running with the arguments 1, 5, and "test" (in
|
|
|
|
that order) on the ``joesguns`` server, and false otherwise:
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
.. code-block:: javascript
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
isRunning("foo.script", "joesguns", 1, 5, "test");
|
2021-04-21 14:20:26 +02:00
|
|
|
|
|
|
|
|
2021-04-29 02:07:26 +02:00
|
|
|
.. js:function:: isRunning(scriptPid)
|
2021-04-21 14:20:26 +02:00
|
|
|
|
|
|
|
:RAM cost: 0.1 GB
|
|
|
|
:param number scriptPid: PID of the script to check.
|
|
|
|
|
|
|
|
Same as the above version but with pid.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
isRunning(39);
|