Jump to content

Question about tracking osbot PID


Recommended Posts

Posted

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 :)

Posted (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 by Explv
Posted (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 by Explv
Posted
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!!!

Posted (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 by Explv
  • Like 2

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