Jump to content

CLI In java freezes bot


BobSmokey

Recommended Posts

                    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
Link to comment
Share on other sites

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
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...