I have a shell script which runs python then attaches a pdf to an email via mutt.
Shell script:
cd ./pod_reports/script/
whereareyou=`pwd`
OUT=`python3 dummy.py`
cd ..
filename=$(ls *.pdf -1t | head -1)
strt="echo Did we get python? "
mailmutt="| mutt -s 'Subject Line' -a $filename -- [email protected]"
stmt="$strt$whereareyou$OUT$mailmutt"
echo $stmt
eval $stmt
Python Script, dummy.py
import sys
OUT = sys.stdout.write(" I did python!! ")
sys.exit(0)
When the shell script is run directly from the command line, I get the expected pwd via 'wherareyou' and the 'I did python!!' statement in the email body, along with the expected attachment. When the script scheduled via crontab, I get the same expected 'whereareyou' and attachment, but I do not get the message from python. My understanding from this is that python is not getting run at all when the shell is executed by crontab.
I don't understand why. Is this somehow expected behavior from crontab? If so, how can a series of scripts be scheduled if not within a shell?