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

57 lines
1.1 KiB
Markdown
Raw Normal View History

2021-10-30 18:34:14 +02:00
<!-- 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.
2021-10-30 18:34:14 +02:00
<b>Signature:</b>
```typescript
2021-10-30 21:46:34 +02:00
ps(host?: string): ProcessInfo[];
2021-10-30 18:34:14 +02:00
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
2021-11-03 05:27:21 +01:00
| host | string | Host address of the target server. If not specified, it will be the current servers IP by default. |
2021-10-30 18:34:14 +02:00
<b>Returns:</b>
[ProcessInfo](./bitburner.processinfo.md)<!-- -->\[\]
Array with general information about all scripts running on the specified target server.
## Remarks
2021-10-30 21:46:34 +02:00
RAM cost: 0.2 GB
2021-10-30 18:34:14 +02:00
Returns an array with general information about all scripts running on the specified target server.
2022-01-08 19:25:06 +01:00
## Example 1
2021-10-30 18:34:14 +02:00
2021-10-30 21:46:34 +02:00
```ts
2022-01-08 19:25:06 +01:00
// NS1:
2022-03-17 21:50:46 +01:00
var scripts = ps("home");
for (var i = 0; i < scripts.length; ++i) {
2022-01-08 19:25:06 +01:00
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) {
2022-03-17 21:50:46 +01:00
ns.tprint(`${script.filename} ${script.threads}`);
2022-01-08 19:25:06 +01:00
ns.tprint(script.args);
2021-10-30 18:34:14 +02:00
}
```