Jump to content

CLI In java freezes bot


Recommended Posts

Posted (edited)
                    String botCommand = "java -jar \"Osbot 2.5.31.jar\" " + "-login "
                            + osbotLogin + " -bot " + bot + " -script " + script + " -world " + world
                            + (extraParams != null ? " " + extraParams : "");

                    Process pr = rt.exec(botCommand);
                    BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                    String line;
                    while ((line = input.readLine()) != null) {
                        //if (line.equalsIgnoreCase("Starting script..."))
                       //     break;
                        System.out.println(line);
                    }

 

UPDATE:

The reason why I want this is to keep track of bots on "-allow lowresource" mode. Is there a better way?

 

 

 

 

Old post:

When I run this, the bot client starts and stops before the login handler comes in. I run this from eclipse and when I disconnect the client from eclipse, it continues.

 

if I add the lines that I commented out, then the script does continue. So this while loop is the cause. How do I make this work and still be able to get the output?

 

Thanks in advance

Edited by BobSmokey
formatting
Posted (edited)

You're trying to get the ouput of the script/bot right? I tried this myself too and it didn't work. There is an option to open a socket with the CLI -debug porthere command and you can listen to this port with for example Python to get the output and store it somewhere. That's how far I got. 

import socket

# creates socket object
s = socket.socket(socket.AF_INET,
                  socket.SOCK_STREAM)

host = socket.gethostname() # or just use (host = '')
port = 5005

s.connect((host, port))

tm = s.recv(1024) # msg can only be 1024 bytes long

s.close()
print("the time we got from the server is %s" % tm.decode('ascii'))

input("enter")

Not sure how to continue, I gave up because I didn't need it anymore after all.

Edited by dormic
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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