Hello, people, I'm trying to run a script in Android in qPython3 (root enabled) that reads an integer "inode" and look for files in the "/proc/" folder such that this number appears in the "/proc/$pid/fd" file and gives me all the "PIDs" (an integer that represents the process in linux) found in /proc such that inode is in the /proc/pid/fd The code is fairly simple and gives me no compile errors but i can't even get the "input" to be displayed. Here is the code:
PS: how do i jump from a line to another in python tag?
PS: how do i jump from a line to another in python tag?
import os def getpid(): inode = input("Insert inode:") # get a list of all files and directories in /proc procFiles = os.listdir("/proc/") # remove the pid of the current python process procFiles.remove(str(os.getpid())) # set up a list object to store valid pids pids = [] for f in procFiles: try: # convert the filename to an integer and back, saving the result to a list integer = int(f) pids.append(str(integer)) except ValueError: # if the filename doesn't convert to an integer, it's not a pid, and we don't care about it pass for pid in pids: # check the fd directory for socket information fds = os.listdir("/proc/%s/fd/" % pid) for fd in fds: # save the pid for sockets matching our inode if ('socket:[%d]' % inode) == os.readlink("/proc/%s/fd/%s" % (pid, fd)): print("%d," % pid) return pid