Hello, good afternoon.
Im a newby user writing my first shell script, and i trying to make it run with the cron utility.
If i run this code manually, the code was sucefull runned, but, when i put in this task in the crontab, the mail dont cant sended.
When i write a ps command, my task look like this:
root 2647 0.0 0.0 1584 640 ? S 18:35 0:00 CROND
root 2648 0.0 0.0 2128 932 ? S 18:35 0:00 /bin/bash -c /root/rmssProject/./rmmsConnection.sh
smmsp 2650 0.0 0.0 0 0 ? Z 18:35 0:00 /usr/sbin/sendmail -FCronDaemon -i -odi -oem root
root 3317 0.0 0.0 1796 500 ? S 18:38 0:00 sleep 2s
...and the mail cant sended. the process stay in stand by, and i dont now why, the cron cant process my script.
The uname command showme this:
Linux host.example.com 2.4.21-9.0.1.ELsmp #1 SMP Mon Feb 9 22:26:51 EST 2004 i686 i686 i386 GNU/Linux
And my code is this:
# Mail subject
SUBJECT="IP'S state"
# to mail's
EMAIL_LIST="ayudamicro@hotmail.com"
ssh [email]script@xxx.xxx.xxx.xxx[/email] < outCommand.ptx | cat > listPop.pop
grep -i '^[a-z][0-9{3}\-][0-9{6}|a-f{6}]' listPop.pop > listCleanPop.pop
LINE=$(wc -l listCleanPop.pop | gawk '/[0-9]+ +*/ {print $1;}')
while test "$LINE" = "0";
do
ssh script@65.200.191.232 < outCommand.ptx | cat > listPop.pop
sleep 2s
grep -i '^[a-z][0-9{3}\-][0-9{6}|a-f{6}]' listaPop.pop > listcleanPop.pop
LINE=$(wc -l listaCleanPop.pop | gawk '/[0-9]+ +*/ {print $1;}')
done
sort listCleanPop.pop > listNewPop.pop
diff listNewPop.pop listBeforePop.pop > diferPop.pop
sed -e "s/^\([0-9]*\)a[0-9]*/The line \1 was added/" diferPop.pop |
sed -e "s/^\([0-9]*\)c[0-9]*/The line \1 was changed/" |
sed -e "s/^\([0-9]*\)d[0-9]*/The line \1 dont stay or was deleted/" |
sed -e "s/^\([0-9]*,[0-9]*\)a[0-9]*/The lines \1 was added/" |
sed -e "s/^\([0-9]*,[0-9]*\)c[0-9]*/The lines \1 was changed/" |
sed -e "s/^\([0-9]*,[0-9]*\)d[0-9]*/The lines \1 dont stay or was deleted/" | cat > mailBodyPop.pop
LINE=$(wc -l mailBodyPop.pop | gawk '/[0-9]+ +*/ {print $1;}')
if test "$LINE" = "0"; then
echo "No changes" | mail -s "$SUBJECT" "$EMAIL_LIST"
else
cp -f listNewPop.pop listBeforePop.pop
cat mailBodyPop.pop | /usr/sbin/sendmail -oi -s "$SUBJECT" "$EMAIL_LIST"
fi
exit 0
Can somebody explainme whats happend here?
Tanks and regards