The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 07-06-2009
dhawalkv dhawalkv is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 4
Hey otheus thanks for the reply....
I took some points from your reply and from few searches in the forum got it working...
here is my script -

Code:
#!/bin/bash

UPLOAD_DIR="/home/xyz/test"
REPORT_DIR="/home/xyz"
UNAME="xyz"
PASS="xyz"
DB="xyz"
URL="http://www.xyz.com/pdf/"

cd $UPLOAD_DIR

for FILENAME in *.pdf
do
	USER_ID=`echo $FILENAME | cut -d "-" -f1`	
	EMAIL_TO=`echo $(mysql -u $UNAME -p$PASS $DB -e "select email from <tablename> where user_id=$USER_ID") | cut -d " " -f2`
	#echo "Send email to $EMAIL_TO"
	BODY="blah blah blah"
	#echo $BODY
	mv $FILENAME $REPORT_DIR
	/usr/sbin/sendmail -t  <<EOF
	From: a@b.com
	To: $EMAIL_TO
	Subject: <subject>
	Content-Type: text/html; charset=us-ascii
	$BODY
	EOF
done
and this is working. i manually run it and i get the email from this.
now when i schedule it in cron, it doesn't execute.....dont know why

here is the line i used in crontab
Code:
1 * * * * /home/xyz/script.sh
trying to run it every minute...but it doesnt get executed. and i'm not even using any environment variables....can you suggest whats wrong?

Thanks...