bitburner-src/markdown/bitburner.ns.ps.md
Meowdoleon c5bf58a3eb
Declaring the script variable in the NS2 example
Small change to declares the script variable in the NS2 example.
2022-01-19 13:58:15 -05:00

57 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [ps](./bitburner.ns.ps.md)
## NS.ps() method
List running scripts on a server.
<b>Signature:</b>
```typescript
ps(host?: string): ProcessInfo[];
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| host | string | Host address of the target server. If not specified, it will be the current servers IP by default. |
<b>Returns:</b>
[ProcessInfo](./bitburner.processinfo.md)<!-- -->\[\]
Array with general information about all scripts running on the specified target server.
## Remarks
RAM cost: 0.2 GB
Returns an array with general information about all scripts running on the specified target server.
## Example 1
```ts
// NS1:
const scripts = ps("home");
for (let i = 0; i < scripts.length; ++i) {
tprint(scripts[i].filename + ' ' + scripts[i].threads);
tprint(scripts[i].args);
}
```
## Example 2
```ts
// NS2:
const ps = ns.ps("home");
for (let script of ps) {
ns.tprint(`${script.filename} ${ps[i].threads}`);
ns.tprint(script.args);
}
```