Jump to content

Search the Community

Showing results for tags 'cli'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • OSBot
    • News & Announcements
    • Community Discussion
    • Bot Manager
    • Support Section
    • Mirror Client VIP
    • Script Factory
  • Scripts
    • Official OSBot Scripts
    • Script Factory
    • Unofficial Scripts & Applications
    • Script Requests
  • Market
    • OSBot Official Voucher Shop
    • Currency
    • Accounts
    • Services
    • Other & Membership Codes
    • Disputes
  • Graphics
    • Graphics
  • Archive

Product Groups

  • Premium Scripts
    • Combat & Slayer
    • Money Making
    • Minigames
    • Others
    • Plugins
    • Agility
    • Mining & Smithing
    • Woodcutting & Firemaking
    • Fishing & Cooking
    • Fletching & Crafting
    • Farming & Herblore
    • Magic & Prayer
    • Hunter
    • Thieving
    • Construction
    • Runecrafting
  • Donations
  • OSBot Membership
  • Backup

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


MSN


Website URL


ICQ


Yahoo


Skype


Location:


Interests

Found 6 results

  1. When i start up a script through cli it works no problems but when i try to open another one (using a diffrent proxy) it says this Java HotSpot(TM) Client VM warning: Using incremental CMS is deprecated and will likely be removed in a future release ERROR: transport error 202: bind failed: Address already in use ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750] Bot exited with code : 2 is there a way to bypass this or is it just the way it is with osbot? Thanks in advandce,
  2. If you've messed with OSBot's CLI, perhaps in creating a bot farm, you've probably messed with the -script CLI argument and using Script.getParameters() in your code. Or maybe you're just looking into automating your OSBot scripts; this guide will show you everything you need to know What are Script Parameters? Parameters are a single String sent to your script via the command line (shell) using the -script CLI argument. It is accessed using Script.getParameters, which may return null if no parameters were provided. You'll need to learn a little bit of String manipulation in Java in order to work with them effectively. Here's some basics to get you started: // To get multiple delimited parameters, use split: // (Warning: you cannot use the comma or pipe character!) String[] params = getParameters().split(";"); // To parse an integer or float from a String, use: int itemsToUse = Integer.parseInt(params[0]); float ratio = Float.parseFloat(params[1]); // Test string equality - use .equals() not == if (params[2].equals("foobar")) log("Foobar mode enabled"); Requirements In order to use -script you must: Provide your OSBot forum credentials via -login Specify an account to log in with via -bot. If your script logs in manually (i.e. you use -allow norandoms and/or disable the auto login random solver then implement your own login handler like Explv's LoginEvent) then you should provide dummy credentials here eg. -bot LOGIN:PASS:0000 Restrictions You cannot use a comma (,) or pipe (|) character within a script name or parameter at all. Doing so may cause various runtime errors like java.lang.NumberFormatException or java.lang.NullPointerException. Most shells have a length limit for commands. See the section below. Escaping Spaces, Double Quotes and Backslashes (with Example) If you are using either spaces ( ), double quotes (") or backslashes in your script name or parameters, you'll need to escape these, potentially twice: once for OSBot, and once for your shell. I'll give an example below for the a script named My "Test" Script with parameters My "Test" Parameters. The example content will be in blue and inserted content will be green. If your script name contains either spaces ( ), double quotes (") or backslashes (\): Insert a backslash (\) before all existing double quotes or backslashes. My \"Test\" Script Surround the whole thing with double quotes that are not escaped with a backslash. "My \"Test\" Script" Do the process above (1) for your script parameters if they contain spaces, double quotes, backslashes: "My \"Test\" Parameters" Combine the script name and parameters with a colon in the middle. "My \"Test\" Script":"My \"Test\" Parameters" This is the raw string to be passed via the command line. If you are using a shell utility or sub-process library that takes an array/list of CLI args, stop here! Such a utility or library should do the next escaping step for you. If you are writing your own .bat/.sh scripts manually, continue on. Before every double quote (") or backslash (\), insert another backslash. \"My \\\"Test\\\" Script\":\"My \\\"Test\\\" Parameters\" Surround the entire thing with double quotes again. "\"My \\\"Test\\\" Script\":\"My \\\"Test\\\" Parameters\"" You're done! Yes, it's ugly, but it should work! Put the result directly after -script in your shell and you're good to go. Here's a combined example: java -jar OSBot.jar -login username:password -bot login:password:bankpin -script "\"My \\\"Test\\\" Script\":\"My \\\"Test\\\" Parameters\"" Once again, this runs a script with the following ScriptManifest name My "Test" Script: @ScriptManifest(name = "My \"Test\" Script", ...) public class MyTestScript extends Script { // .. } Using Files Instead of Script Parameters Sometimes shells can have surprisingly low limits on command length. If you expect your script input to be long (such as JSON, CSV or XML), you should be loading these from file instead instead of stuffing them in script parameters! These data formats may also contain incompatible characters (comma and pipe). Here's a few short examples to get you started (this isn't a guide on reading text from files in Java...) String filePath = getDirectoryData() + File.separator + getParameters(); File fp = new File(filePath); BufferedReader in = new BufferedReader(new FileReader(fp)); String line; while ((line = in.readLine()) != null) { // Process one line of input. } in.close(); If you want the entire file contents read into a string, you can use Files.readAllBytes and Paths.get: String filePath = getDirectoryData() + File.separator + getParameters(); String fileContent = new String(Files.readAllBytes(Paths.get(filePath))); Finally, using files has an added benefit of being able to provide default input data when script parameters aren't available (ie. the script was run via the Script Selector window): String filePath = getDirectoryData() + File.separator + (getParameters() != null ? getParameters() : "myDefaultInput.txt")); // Use the filePath as above And as usual, catch FileNotFound and other IOExceptions as necessary. Using files is a much better way to load in data than a lengthy script parameter! Additional Tips If you're having trouble escaping things properly, perhaps it's better to question if including the escaped content is even necessary at all. In other words, if it's easier to not name scripts using spaces, quotes or backslashes, then do that instead of escaping. Simplicity is better than being smart. For a good user experience, provide sensible defaults if parameters aren't provided. If your script requires input and can't come up with defaults, try using the Java Swing framework to show a UI (see Explv's AIO if you need an example). DON'T USE COMMAS (,) OR PIPE CHARACTERS (|) AS DELIMITERS. They aren't allowed and will break OSBot! If you need to delimit a parameter string, try a healthy low-carb alternative of a semicolon.
  3. This is the code that I'm using. My script is local. (the name is FishNetLooter) This is the path that it's set in CMD prompt gives me this error! So my question is, why cant it find the script and how do I make it load? I tried changing the name in the cmd file with the .jar extention but it still doesn't find the script. Any help would greatly be appreciated, thank you!
  4. I've expanded upon my CLI Support Made Easy to build a fully functional file reader/writer for each script. So assume you're launching a fighting script with the following CLI: -script Fighter:scrub.ini.noob.ini.body.green-d'hide-body.legs.green-d'hide-chaps That'll get converted to: scrub.ini -to- OSBot/data/Fighter/scrub.ini noob.ini -to- OSBot/data/Fighter/noob.ini body:green d'hide body legs:green d'hide chaps Also, there'll be a OSBot/data/Fighter/default.ini created too. The default.ini file is where you specify parameters you want to share for every bot. These files will be created automatically (if they're not already present) and loaded: Anything that you put in the CLI that isn't a .ini file, those will be added (and override) all the key/values plucked from the files. This is similar to when you add inline CSS to HTML elements and how that potentially overrides the CSS loaded in from .css files. Example script code: @ScriptManifest(author = "", info = "", logo = "", name = "Fighter", version = 0) public class CLITest extends Script { NPC npc; ScriptFile scriptFile; Properties cli; @Override public void onStart() throws InterruptedException { String parameters = getParameters(); try { if (parameters != null && !parameters.isEmpty()) { scriptFile = ScriptFile.compileAndCollateScriptIniFiles(getName(), getVersion(), getParameters()); cli = scriptFile.getProperties(); } } catch (IOException e) { e.printStackTrace(); } } @Override public int onLoop() throws InterruptedException { npc = npcs.closest(cli.getProperty("target", "Guard")); return 250; } } So let's say we had noob.ini and we wanted to target a tramp The script will then use that But let's say you didn't specify "target", probably because you misspelled it The CLI parameter "target" isn't specified, so the script will look for a guard instead Source code:
  5. Here's a quick way to get key/value pairs from your CLI parameters. We can take: -script TestScript:body.green-d'hide-body.legs.preists-robes.location.varrock.mode.attack And convert it to: BODY:green d'hide body LEGS:priests robes LOCATION:varrock MODE:attack You're probably wondering 'why are the keys uppercase?', well that's to signify what the bot thinks are keys. A little debugging and you'll be able to see what your bot sees. The full-stop "." is our delimiter, and the hyphen "-" is our replacement for the space " " key. Example code + template: public class Test extends Script { Map<String, String> parameters; String mode; @Override public void onStart() throws InterruptedException { compileParameters(); mode = parameters.get("mode"); } @Override public int onLoop() throws InterruptedException { // log out the parameters for debugging purposes logger.debug(parameters); // use parameters if (mode != null && !mode.isEmpty()) { if (mode.equals("attack")) { // TODO - attack something } } return 1000; } /** * Compiles OSBot parameters into key/value pairs */ private void compileParameters() { String rawParameterString = getParameters(); String[] contents; String key; String value; parameters = new HashMap<>(); if (rawParameterString != null && !rawParameterString.isEmpty()) { logger.debug(rawParameterString); contents = rawParameterString.split("\\."); if (contents != null && contents.length > 0) { for (int i = 0; i < contents.length; i += 2) { key = contents[i]; key = key.toUpperCase(); value = (i + 1 < contents.length ? contents[i + 1] : ""); value = value.replaceAll("-", " "); parameters.put(key, value); } } } } } Have fun!
  6. A very simple CLI Script Creator. Helps you create CLI scripts with ease without having to copy, paste, and edit over and over. Hope it helps make your botting career a bit easier! Dependencies: Requires Python 3.6.1 or higher to run. Python download: https://www.python.org/downloads/ Here is the link to the GitHub repo: https://github.com/Tylersobored/MakeBat Latest Version: 0.4.1 Changelog: v0.4.1 - Added random worlds (type "f2p" or "p2p" in world parameter) v0.4 - Fixed bugs when updating bots v0.3 - Added ability to select multiple bots and update them accordingly. - Added Update All and Import Proxies buttons
×
×
  • Create New...