

There's a better way to do this in Javascript as well, but I write it like this so you can easily understand what's happening.


Still, as a base script, I think it's fairly easy to figure out what I'm doing here and then build out to your own requirements.Īdditionally, if you're manually editing the hostname in your attack scripts, write something that uses something more like this: I just use this one to scan hosts and deploy my most basic scripts, but other than that, I've moved most of this functionality to other scripts to schedule and prevent overhacking, etc, etc. Like I said, though, there are MUCH better scripts on the forums if you poke around. Or, if you know you want to kill any running script, you could just do an ns.killall() and restart the scripts that you just redeployed. It will automatically scan everything, root anything you can, and deploy an attack, grow, and weaken script to every host that you root.īy adding a single if/else statement on or just before line 62, you can kill actively running scripts on the server and deploy whatever you want. Once I get done writing my Singularity scripts I'll revisit this, but this should help you. In all fairness, I didn't write the base of this script, I got it off of Reddit to get me started and then slowly changed it and added to it until it was functionally usable for me. If you look at line 62 of this script, that's the perfect place to put an if ns.isRunning() - check and see if a script is running on the host that you're attacking, then use ns.kill to stop that script from running. There are a lot of optimizations that I would make now if I were to write this script - when I started Bitburner, I didn't know anything about Javascript. This is the deployment script that I'm currently running. So no, It's not necessary, nor does it really matter, I just wanted to save time. Scp works fine for updating the script on the remote hosts, it's just that remoting into each of the hosts to edit the hostname in the script, kill the process and start it again can be a little bit tedious when you have a lot of different spokes you're updating. I made a change to the ns script I use for continuous hacking/growing/weakening, the only purpose of this is to run a quick terminal script that allows me to immediately log into the remote host and edit the ns script as it exists on the remote host. Look at the ns.scp() command (literally, the same as the real-world command, only simpler) to place a local file on the remote host. Likewise, copy/paste into nano on a remote host isn't necessary. Think of it as similar to Cisco Prime or another management interface you hit the button on the management server, it manages the deployment and execution on the remote host. Otherwise, you can do remote execution of local scripts via ns.exec(). Are you trying to backdoor the target server? That's really the only reason to manage a connect script. Originally posted by helix0704:Not sure the purpose behind this.
