Made a simple script for android (really simple) but it is not running - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Made a simple script for android (really simple) but it is not running (/thread-16583.html) |
Made a simple script for android (really simple) but it is not running - anddontyoucomebacknomore - Mar-05-2019 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? 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 RE: Made a simple script for android (really simple) but it is not running - Yoriz - Mar-06-2019 I have tried formatting your code, not totally sure if I've got all the indention correct. it seems you have not called. getpid() RE: Made a simple script for android (really simple) but it is not running - anddontyoucomebacknomore - Mar-06-2019 Thank you very much! It is running now |