Jump to content

Question about tracking osbot PID


throwaway1237843

Recommended Posts

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

Link to comment
Share on other sites

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

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

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

Link to comment
Share on other sites

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

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 by throwaway1237843
  • 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...