![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Monitor capacity of directory | LRoberts | Shell Programming and Scripting | 1 | 06-01-2009 12:58 PM |
| script to monitor files in a directory and sending the alert | shellscripter | Shell Programming and Scripting | 0 | 11-26-2008 02:26 AM |
| script to monitor directory | nulinux | Shell Programming and Scripting | 17 | 08-22-2008 11:28 AM |
| Hep with script to monitor directory | cmf00186 | UNIX for Dummies Questions & Answers | 2 | 10-25-2006 03:42 PM |
| Monitor which users enter my home directory | mnpradeep | High Level Programming | 1 | 03-21-2002 05:08 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Monitor directory and email
Hello all,
Can anyone please guide / help me in the following task.... I have a directory where some external users will upload pdf files. The filename of these pdf will be of a particular format (<id>-<first name>_<last name>_<some number>.pdf) I want to make a script such that it takes (splits) the id from the filename and query the mysql database for the email address of that id (this can be done from a php script also) and then email on that particular id. Also this script has to run periodically (many times in a day...this can be done from cron). I need some guidance on how to go about this.....whether this can be done from a shell script or php script and some help with the commands if shell script. My knowledge on PHP also is not very good, so if there are any inputs for using php then just guide me along. Thanks.... |
|
||||
|
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... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|