I'm using subprocess within a python script to send variables into a bash script which is designed to send emails.
My python code:
import re
import subprocess
message="https://example.com/"
subprocess.run(["./send_email.bash",message])
My "./send_email.bash" script:
#!/bin/bash
body=$1
echo "$body" | ssmtp example@gmail.com
It keeps sending a blank email. However, if I use a string which doesn't come from subprocess, the email contains it. There may be a better way of doing this, but the point of my post is to understand why this doesn't work. What perplexes me is that the variable sent from subprocess may be appended to a file. But, it cannot be recognized by loops or "if" expressions. etc.
Thank you!