User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 391,570 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,657 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Views: 3225 | Replies: 1 | Solved
Reply
Join Date: Apr 2006
Location: Mexico DF
Posts: 3
Reputation: elidio is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
elidio's Avatar
elidio elidio is offline Offline
Newbie Poster

Help sendmail problem using cron

  #1  
Apr 26th, 2006
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 script@xxx.xxx.xxx.xxx < 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
--------------
Elidio I. Marquina Ordon~ez
Programing surfer
The game is never over
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2006
Location: Mexico DF
Posts: 3
Reputation: elidio is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
elidio's Avatar
elidio elidio is offline Offline
Newbie Poster

Solution Re: sendmail problem using cron

  #2  
Apr 27th, 2006
Finally i can solve my problem.
I added the FULL PATH for the commands and my own files. These solve the problem.

Originally Posted by elidio
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 script@xxx.xxx.xxx.xxx < 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
--------------
Elidio I. Marquina Ordon~ez
Programing surfer
The game is never over
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Shell Scripting Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 10:17 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC