utils/README.md
2021-06-16 20:22:07 +03:00

68 lines
2.1 KiB
Markdown

# utils
* [sendmail.py](https://git.hmp.today/pavel.muhortov/utils#sendmail-py)
* [srchproc.py](https://git.hmp.today/pavel.muhortov/utils#srchproc-py)
____
## sendmail.py
| PARAMETERS | DESCRIPTION | DEFAULT|
|-------------|-------------|--------|
|**-u**, **--user**|smtp valid user|**REQUIRED**|
|**-p**, **--pass**|smtp valid password|**REQUIRED**|
|**-d**, **--dest**|destination addresses|**REQUIRED**|
|**[-h]**|print help and exit||
|**[--smtp]**|smtp hostname or ip address|smtp.gmail.com|
|**[--port]**|smtp port number|587|
|**[--stls]**|smtp required TLS|`True`|
|**[--from]**|mail from alias|**--user** value|
|**[--subj]**|mail subject|'no subject'|
|**[--text]**|mail body text|'no text'|
|**[--type]**|mail body type: plain, html|plain|
|**[--file]**|mail attachment files|`None`|
Example usage in terminal with Python:
```shell
python3 ./sendmail.py -u user@gmail.com -p pass -d addr1@gmail.com,addr2@gmail.com
```
Example usage in terminal with make the script executable:
```shell
chmod u+x ./sendmail.py
./sendmail.py -u user@gmail.com -p pass -d addr1@gmail.com,addr2@gmail.com
```
Example usage in Python:
```Python
from sendmail import Mail
msg = Mail(smtp_user='user@gmail.com', smtp_pass='pass', mail_dest='addr1@gmail.com,addr2@gmail.com')
log = msg.send()
print(log)
```
____
## srchproc.py
| PARAMETERS | DESCRIPTION | DEFAULT|
|-------------|-------------|--------|
|**[-h]**|print help and exit||
|**[--find]**|find process pid, name or arguments||
|**[--exclude]**|exclude process pid, name or arguments|`None`|
|**[--self]**|find a clones of self|`True`|
Example usage in terminal with Python for find all running processes:
```shell
python3 ./srchproc.py
```
Example usage in terminal with make the script executable for find all specified processes:
```shell
chmod u+x ./sendmail.py
./srchproc.py --find ssh --exclude sftp
```
Example usage in Python for find a clones of self:
```Python
from os import getpid
from sys import argv
from srchproc import Proc
processes = Proc.search(' '.join(argv), str(getpid()))
if processes:
for process in processes:
print(process)
```