throwaway1237843 Posted September 23, 2018 Share Posted September 23, 2018 Hi All, My automuling system tracks each osbot client PID as it opens and then task kills the client when it is time to mule. However this seems to be only working about 75% of the time now - the rest of the time i am getting "ERROR: The process "XXXX" is not found". This is probably a dumb question but does the OSbot PID change, or am i just pulling a wrong PID? Thanks Quote Link to comment Share on other sites More sharing options...
Explv Posted September 23, 2018 Share Posted September 23, 2018 (edited) 23 minutes ago, throwaway1237843 said: Hi All, My automuling system tracks each osbot client PID as it opens and then task kills the client when it is time to mule. However this seems to be only working about 75% of the time now - the rest of the time i am getting "ERROR: The process "XXXX" is not found". This is probably a dumb question but does the OSbot PID change, or am i just pulling a wrong PID? Thanks How are you starting the OSBot processes and getting the PIDs? show your code And no, the PID of a given process does not change throughout that process' lifetime. Edited September 23, 2018 by Explv Quote Link to comment Share on other sites More sharing options...
throwaway1237843 Posted September 23, 2018 Author Share Posted September 23, 2018 (edited) This is where I pull all the java PIDs before starting up a client. This goes into a list, then I open a new client, pull all the PIDS again, compare the two lists and extract the new value. Bots are started with CLI also Edited September 24, 2018 by throwaway1237843 Quote Link to comment Share on other sites More sharing options...
throwaway1237843 Posted September 23, 2018 Author Share Posted September 23, 2018 java -jar "C:\Users\XXXX\Downloads\osbot 2.5.22.jar" -login XXXXX:XXXXXX -bot %mule% -script "Automuler-reciever_dye":null -proxy %muleproxy% -world 326 -allow lowresource example of my launcher Quote Link to comment Share on other sites More sharing options...
Explv Posted September 23, 2018 Share Posted September 23, 2018 (edited) 26 minutes ago, throwaway1237843 said: This is where I pull all the java PIDs before starting up a client. This goes into a list, then I open a new client, pull all the PIDS again, compare the two lists and extract the new value. Bots are started with CLI also OK that's fine, probably what isn't working for you is the fact that OSBot starts two processes. The first process is the boot menu where you type your login details. When you click login, a new process is started for the actual client, and the boot menu process exits. For example: # Boot menu opens C:\Users\Explv>tasklist /FI "IMAGENAME eq java.exe" /NH java.exe 5304 Console 2 51,772 K # Client opens C:\Users\Explv>tasklist /FI "IMAGENAME eq java.exe" /NH java.exe 15692 Console 2 37,620 K You have two options: 1. Add a sleep long enough to let OSBot boot up properly and for the client to open, and then get the PIDs or 2 (recommended) Use Python/Java/Whatever programming language to run OSBot (in debug mode) and read the output. When the output contains "Successfully loaded OSBot!" you know that the client has fully booted and you can get the PID using tasklist. Here is an example I wrote in Java https://github.com/Explv/osbot_manager/blob/master/osbot_manager/src/bot_parameters/configuration/Configuration.java#L347 Edited September 23, 2018 by Explv Quote Link to comment Share on other sites More sharing options...
throwaway1237843 Posted September 23, 2018 Author Share Posted September 23, 2018 2 minutes ago, Explv said: OK that's fine, probably what isn't working for you is the fact that OSBot starts two processes. The first process is the boot menu where you type your login details. When you click login, a new process is started for the actual client, and the boot menu process exits. For example: # Boot menu opens C:\Users\Explv>tasklist /FI "IMAGENAME eq java.exe" /NH java.exe 5304 Console 2 51,772 K # Client opens C:\Users\Explv>tasklist /FI "IMAGENAME eq java.exe" /NH java.exe 15692 Console 2 37,620 K You have two options: 1. Add a sleep long enough to let OSBot boot up properly and for the client to open, and then get the PIDs or 2 (recommended) Use Python/Java/Whatever programming language to run OSBot (in debug mode) and read the output. When the output contains "OSBot is now ready!" you know that the client has fully booted and you can get the PID using tasklist. Here is an example I wrote in Java https://github.com/Explv/osbot_manager/blob/master/osbot_manager/src/bot_parameters/configuration/Configuration.java#L347 Ah okay, I will play around with that. Thank you!!! Quote Link to comment Share on other sites More sharing options...
Explv Posted September 23, 2018 Share Posted September 23, 2018 (edited) 24 minutes ago, throwaway1237843 said: Ah okay, I will play around with that. Thank you!!! Here is another example using Python: import subprocess OSBOT_PATH = "C:\\Users\\Explv\\Downloads\\OSBot 2.5.22.jar" OSBOT_USER = "" OSBOT_PASS = "" def main(): cmd = ["java", "-jar", OSBOT_PATH, "-login", OSBOT_USER + ":" + OSBOT_PASS, "-debug"] popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True) prev_pids = get_java_pids() for stdout_line in iter(popen.stdout.readline, ""): print(stdout_line) if "Successfully loaded OSBot!" in stdout_line: break popen.stdout.close() new_pids = get_java_pids() current_osbot_pid = new_pids - prev_pids if len(current_osbot_pid) > 1: raise ValueError('More than one new Java PID found') print("OSBot PID is: " + next(iter(current_osbot_pid))) def get_java_pids(): pids = set() java_processes = subprocess.check_output("tasklist /FI \"IMAGENAME eq java.exe\" /NH") for java_process in java_processes.decode('utf-8').splitlines(): if len(java_process.strip()) > 0: pid = java_process.split()[1] pids.add(pid) return pids if __name__ == '__main__': main() Edited September 23, 2018 by Explv 2 Quote Link to comment Share on other sites More sharing options...
throwaway1237843 Posted September 23, 2018 Author Share Posted September 23, 2018 (edited) Actually it turns out the problem is if my PID is 5 digits the first digit is getting chopped off when i extract it . Now just need to figure out why lol edit: just needed to delete !PIDS:~1,-1!, and added a small sleep Thanks! Edited September 23, 2018 by throwaway1237843 1 Quote Link to comment Share on other sites More sharing options...