mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-25 07:32:27 +01:00
added ps function to netscript, returns the list of processes currently running on that server
This commit is contained in:
parent
71cf3cac35
commit
758f00419b
@ -948,6 +948,23 @@ function NetscriptFunctions(workerScript) {
|
|||||||
allFiles.sort();
|
allFiles.sort();
|
||||||
return allFiles;
|
return allFiles;
|
||||||
},
|
},
|
||||||
|
ps : function(ip=workerScript.serverIp) {
|
||||||
|
if (workerScript.checkingRam) {
|
||||||
|
return updateStaticRam("ps", CONSTANTS.ScriptScanRamCost);
|
||||||
|
}
|
||||||
|
updateDynamicRam("ps", CONSTANTS.ScriptScanRamCost);
|
||||||
|
var server = getServer(ip);
|
||||||
|
if (server == null){
|
||||||
|
workerScript.scriptRef.log("ps() failed. Invalid IP or hostname passed in: " + ip);
|
||||||
|
throw makeRuntimeRejectMsg(workerScript, "ps() failed. Invalid IP or hostname passed in: " + ip);
|
||||||
|
}
|
||||||
|
const processes = [];
|
||||||
|
for(const i in server.runningScripts) {
|
||||||
|
const script = server.runningScripts[i];
|
||||||
|
processes.push({filename:script.filename, threads: script.threads, args: script.args.slice()})
|
||||||
|
}
|
||||||
|
return processes;
|
||||||
|
},
|
||||||
hasRootAccess : function(ip) {
|
hasRootAccess : function(ip) {
|
||||||
if (workerScript.checkingRam) {
|
if (workerScript.checkingRam) {
|
||||||
return updateStaticRam("hasRootAccess", CONSTANTS.ScriptHasRootAccessRamCost);
|
return updateStaticRam("hasRootAccess", CONSTANTS.ScriptHasRootAccessRamCost);
|
||||||
|
Loading…
Reference in New Issue
Block a user