Butters Posted July 20, 2017 Share Posted July 20, 2017 Hey, I;m having trouble debugging my system and need help getting the full log of what's going on. I'm using Linux and run quite a few bots on one machine. I wanted to either redirect all bot output logs to certain files or to keep the terminals open after the bot dies (this is the way I made stuff - kill the bot when it's done with System.exit(0);) 1. Grabbing output from a known debug port Let's say bot uses debug port 5011. Tried using nc to listen for output on the mentioned port, though says that the port is already being used. Any better tools out there? 2. Keeping the terminal alive after bot dies I start bots on their own terminal each time, using something like "xterm -e java -jar osbot.jar ........." Now when the bot dies, the terminal closes, and bye bye all logs, error messages and etc. I noticed that after osbot handles the login info it launches a new process or something to start the bot client so something like "xterm -hold -e java -jar osbot.jar...." or "xter -e "java -jar osbot.jar;read" doesn't work as it stops doing stuff adter the login screen (even when I bypass it with -login flag), So any ideas how to solve this? In short I think I get some error message when I start a bot and I dunno what happened, the terminal closes immediatelly, overrding the log() method didn't help much either. Quote Link to comment Share on other sites More sharing options...
IDontEB Posted July 20, 2017 Share Posted July 20, 2017 (edited) I believe you need to connect a socket to the port you're debugging on and then use something like: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.Socket; import java.net.UnknownHostException; public class Debugger { private static Socket socket; private static OutputStream outputStream; public static void main(String[] args) throws UnknownHostException, IOException { socket = new Socket("127.0.0.1", 5123); outputStream = socket.getOutputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); String line; while ((line = reader.readLine()) != null){ System.out.println(line); } } } You can copy and paste that and it will be its on command line which should store everything. feel free to modify to print to a text file if you want. edit: 5123 is the port in there Edited July 20, 2017 by IDontEvenBot 1 Quote Link to comment Share on other sites More sharing options...
Butters Posted July 20, 2017 Author Share Posted July 20, 2017 20 minutes ago, IDontEvenBot said: I believe you need to connect a socket to the port you're debugging on and then use something like: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.Socket; import java.net.UnknownHostException; public class Debugger { private static Socket socket; private static OutputStream outputStream; public static void main(String[] args) throws UnknownHostException, IOException { socket = new Socket("127.0.0.1", 5123); outputStream = socket.getOutputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); String line; while ((line = reader.readLine()) != null){ System.out.println(line); } } } You can copy and paste that and it will be its on command line which should store everything. feel free to modify to print to a text file if you want. edit: 5123 is the port in there Thanks, will try this out. Somehow didn't think that OSBot runs a socket server for this Quote Link to comment Share on other sites More sharing options...
IDontEB Posted July 20, 2017 Share Posted July 20, 2017 10 minutes ago, nosepicker said: Thanks, will try this out. Somehow didn't think that OSBot runs a socket server for this Yeah, I didnt know either but only found out when It said socket already in use when I tried to make a server socket for it to connect too. Cheers Quote Link to comment Share on other sites More sharing options...
Butters Posted July 20, 2017 Author Share Posted July 20, 2017 Somehow the input stream is empty even though the bot is running and I connected successfully. Any ideas? Connected to the correct port ofc. Quote Link to comment Share on other sites More sharing options...
IDontEB Posted July 20, 2017 Share Posted July 20, 2017 48 minutes ago, nosepicker said: Somehow the input stream is empty even though the bot is running and I connected successfully. Any ideas? Connected to the correct port ofc. Didnt actually test it I just knew it wanted a socket connection on that port. After looking into it I cannot get anything to connect. Since it says it's waiting for transport dt_socket I think it wants us to use "jdb -attach 5005" in a separate cmd window to connect but that one doesnt connect either. Quote Link to comment Share on other sites More sharing options...
Butters Posted July 20, 2017 Author Share Posted July 20, 2017 38 minutes ago, IDontEvenBot said: Didnt actually test it I just knew it wanted a socket connection on that port. After looking into it I cannot get anything to connect. Since it says it's waiting for transport dt_socket I think it wants us to use "jdb -attach 5005" in a separate cmd window to connect but that one doesnt connect either. To my understanding, when osbot starts with -debug flag it starts a socket server on the specified port. So if OSBot is not running - you don't have where to connect. All fine and dandy, though somehow the inputStream is empty and doesn't provide me the log messages. All nulls. Maybe someone who messed around with this more could enlighten us? Quote Link to comment Share on other sites More sharing options...