Jump to content

Start bot in java application


The Undefeated

Recommended Posts

I use this code to start the bot in a java application:

        String completeCLI = "java -jar \"root/Desktop/osbot.jar\"";
        System.out.println(completeCLI);
        Process proc = Runtime.getRuntime().exec(completeCLI);
        proc.waitFor();

This works in Windows, but not in Ubuntu. Anyone knows how I can start my client in Ubuntu?

 

Link to comment
Share on other sites

11 minutes ago, The Undefeated said:

I use this code to start the bot in a java application:


        String completeCLI = "java -jar \"root/Desktop/osbot.jar\"";
        System.out.println(completeCLI);
        Process proc = Runtime.getRuntime().exec(completeCLI);
        proc.waitFor();

This works in Windows, but not in Ubuntu. Anyone knows how I can start my client in Ubuntu?

 

 

Tested and seems to work:

ProcessBuilder processBuilder = new ProcessBuilder("java", "-jar", "/home/user/explv/Downloads/OSBot 2.4.121.jar");
processBuilder.start();

 

Edited by Explv
Link to comment
Share on other sites

14 minutes ago, Explv said:

 

Tested and seems to work:


ProcessBuilder processBuilder = new ProcessBuilder("java", "-jar", "/home/user/explv/Downloads/OSBot 2.4.121.jar");
processBuilder.start();

 

But how can I add CLI parameters to it now? Can't figure that out.

ProcessBuilder doesn't allow a 3rd argument.

Edited by The Undefeated
Link to comment
Share on other sites

16 minutes ago, The Undefeated said:

But how can I add CLI parameters to it now? Can't figure that out.

ProcessBuilder doesn't allow a 3rd argument.

The ProcessBuilder constructor accepts either a List<String> or String...

Each item in the List or String[] is one parameter of the command.

So, for example:

List<String> command = new ArrayList<>();
Collections.addAll(command, "java", "-jar", "/path/to/osbot.jar", "-script", "890:none");
ProcessBuilder pBuilder = new ProcessBuilder(command);

or

String[] command = {"java", "-jar", "/path/to/osbot.jar", "-script", "890:none"};
ProcessBuilder pBuilder = new ProcessBuilder(command);

or

ProcessBuilder pBuilder = new ProcessBuilder("java", "-jar", "/path/to/osbot.jar", "-script", "890:none");

 

Edited by Explv
Link to comment
Share on other sites

33 minutes ago, Explv said:

The ProcessBuilder constructor accepts either a List<String> or String...

Each item in the List or String[] is one parameter of the command.

So, for example:


List<String> command = new ArrayList<>();
Collections.addAll(command, "java", "-jar", "/path/to/osbot.jar", "-script", "890:none");
ProcessBuilder pBuilder = new ProcessBuilder(command);

or


String[] command = {"java", "-jar", "/path/to/osbot.jar", "-script", "890:none"};
ProcessBuilder pBuilder = new ProcessBuilder(command);

or


ProcessBuilder pBuilder = new ProcessBuilder("java", "-jar", "/path/to/osbot.jar", "-script", "890:none");

 

This only starts the bot and doesn't log it in.

String[] command = {"java","-jar","osbot.jar","-login \"The Undefeated\":password"};
        ProcessBuilder pBuilder = new ProcessBuilder(command);
        pBuilder.start();
Edited by The Undefeated
Link to comment
Share on other sites

20 minutes ago, The Undefeated said:

This only starts the bot and doesn't log it in.


String[] command = {"java","-jar","osbot.jar","-login \"The Undefeated\":password"};
        ProcessBuilder pBuilder = new ProcessBuilder(command);
        pBuilder.start();

"-login" and "username:password" should be two separate items in the array:

String[] command = {"java","-jar","osbot.jar","-login", "\"The Undefeated\":password"};

 

Link to comment
Share on other sites

8 minutes ago, Explv said:

"-login" and "username:password" should be two separate items in the array:


String[] command = {"java","-jar","osbot.jar","-login", "\"The Undefeated\":password"};

 

Forgot to mention I already tested that and didn't even start, might be caused by the space in my name. Even tried it like this but won't start either.

String[] command = {"java","-jar","osbot.jar","-login", "\"The", "Undefeated\":password"};

 

Edited by The Undefeated
Link to comment
Share on other sites

33 minutes ago, The Undefeated said:

Shows the exact same behavior as I stated in my comment above.

 

Oh sorry I thought you knew. You need your own login handler since all randoms are disabled, or if your using non-cli paramters and just using this to start simple scripts then you can remove the -norandoms flag in my code.

If you end up using the custom login handler, you will need to pass the bot login info as parameters since you cant access those hidden fields normally. You can make your own or I think Explv may have a snippet of some somewhere on here.

Edited by LoudPacks
Link to comment
Share on other sites

10 hours ago, LoudPacks said:

Oh sorry I thought you knew. You need your own login handler since all randoms are disabled, or if your using non-cli paramters and just using this to start simple scripts then you can remove the -norandoms flag in my code.

If you end up using the custom login handler, you will need to pass the bot login info as parameters since you cant access those hidden fields normally. You can make your own or I think Explv may have a snippet of some somewhere on here.

If you read my post above I said the whole client doesn't even start. I know what norandoms does and I have my own login handler but those make no sense if I can't even open the client.

EDIT: Got it working by putting my username in quotation marks.

 

Edited by The Undefeated
Link to comment
Share on other sites

13 hours ago, The Undefeated said:

Forgot to mention I already tested that and didn't even start, might be caused by the space in my name. Even tried it like this but won't start either.


String[] command = {"java","-jar","osbot.jar","-login", "\"The", "Undefeated\":password"};

 

 

Try:

String[] command = {"java", "-jar", "osbot.jar", "-login", "\"\\\"The Undefeated\\\":password\""};

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...