#!/usr/bin/python3 import os import sys import pwd import queue def ProcessDir(theDir): Q = queue.Queue() Q.put(theDir) while not Q.empty(): aDir = Q.get() print ("Processing " , aDir) ProcessADir(aDir,Q) def ProcessADir(theDir,Q): for aFile in os.scandir(theDir): print ("\t Entry ", aFile.name ) print ("\t\t Has inode ", aFile.inode() ) if aFile.is_dir(follow_symlinks=False): print("\t\tIt's a Directory") if (aFile.name != '.' and aFile.name != ".."): print ("\t\t\tAdding ", aFile.path, " to the queue") Q.put(aFile.path) elif aFile.is_file(follow_symlinks=False): print("\t\tIt's a file") elif aFile.is_symlink(): print("\t\tIt's a symlink") else: print("\t\tSome Other File") print("") statRes = aFile.stat(follow_symlinks=False) print ("\t\tUser ID: ",statRes.st_uid) passwdRes = pwd.getpwuid(statRes.st_uid) print ("\t\tOr Username: ", passwdRes.pw_name); print (" ") i = 1 while i < len(sys.argv): ProcessDir(sys.argv[i]); i += 1