Library
execute_cmd_print
Execute terminal command and print the output.
def execute_cmd_print(cmd):
print(popen(cmd).read())
find_task_pid
Finds process id using ps ax piped into a grep command. Return the active process id as an integer or false.
def find_task_pid(task, find):
r = popen(f'ps ax | grep {task}').read().split('\n')
for i in range(len(r)):
if search(find, r[i]):
re = r[i].split(' ')
l = 1
while re[l] == "":
l = l + 1
return int(re[l])
return False
execute_mail
Sends email by use of the system mail command. Note that postfix or other system must be installed and configured correctly for this function to work.
def execute_mail(msg, subject, sender, recip):
popen(f'echo "{msg}" | mail -s "{subject}" From:{sender} {recip}')