Quoted By:
>/** @param {NS} ns **/
>export async function main(ns) {
> var program = ns.args[0];
> var allServ = ns.scan();
> var fRam;
> var tRam;
> var uRam;
> var fServ = [];
> var prgmRam = ns.getScriptRam(program);
>
>
> var mThreads = Math.floor(fRam / >prgmRam);
> function chkRam(server) {
> tRam = ns.getServerMaxRam(server);
> uRam = ns.getServerUsedRam(server);
> fRam = tRam - uRam;
> if (fRam > prgmRam) {
> return true;
> }
> }
>
> function updateSrv(server, thred) {
> ns.scp(program, 'home', server);
> ns.tprint('Connecting to ' + server + '...' + >'\n');
> ns.connect(server);
> ns.tprint('Running ' + program + ' with ' + >mThreads + ' threads on ' + server + '...' + '\n');
> ns.run(program, thred);
> }
> if (await ns.prompt("\n Are you sure?" + '\n' >+ "Uploading and executing your payload may >cause all other scripts to be killed in the >proccess!!!") == true) {
> ns.tprint('\n' + 'Updating the following >servers: ')
> for (var i = 0; i != allServ.length; i++) {
> ns.tprint(allServ);
> }
> for (var i = 0; i != allServ.length; i++) {
> if (chkRam(allServ) == true) {
> updateSrv(allServ, mThreads);
> } else {
> if(await ns.prompt("There is not >enough ram on "+allServ+'!\n'+'Kill all >processess?')){
> ns.connect(allServ);
> ns.killall
>
> }
> }
> }
> } else {
> ns.tprint("Aborted!");
> }
>}