Linux / UNIX Tech Support Forum
This is a discussion on Ubuntu Linux File Upload / Creation Email Notification within the Ubuntu / Debian forums, part of the Linux Distribution category; Good afternoon. I recently set up an SFTP server on one of our servers, and I have two issues I ...
|
|||||||
| Ubuntu / Debian Discussion about Debian or Ubuntu Linux related problems. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Good afternoon.
I recently set up an SFTP server on one of our servers, and I have two issues I wanted to get resolved and I can't figure out an easy way to do it. 1. I would like an automatic email to be generated and sent to the user that uploaded a file to the FTP server. For example, it would state that <name of file> has been received at <time> on <date>. 2. I would also like an email generated and sent to an internal email group about any file that is uploaded to the server. For example, it would show: A new <file name> file has been uploaded in <folder name> on <date> at <server time>. If anyone knows of a way to accomplish this, and could possibly help me out in a walk through of getting this set up, I would really appreciate it. Thank you. |
| Sponsored Links | ||
|
|
|
||||
|
How do you upload file? Do you use a script to upload file or it is done by someone else by typing commands or sftp client?
If it is a script, the same script can send an email update. If it is a manual method, you can use something called file FAM. It can monitors files and directories, notifying changes including new files. You need to install dnotify program using apt-get command: Code:
apt-get install dnotify Code:
dnotify -C /tmp -e echo "File Created" Code:
dnotify -CD /var/pub/ftp -e /path/to/script PHP Code:
__________________
Vivek Gite Linux Evangelist |
| The Following User Says Thank You to nixcraft For This Useful Post: | ||
raj (17-06-2009)
| ||
|
||||
|
dnotify is user land tool and do not requires to write code in C / C++ or other supported API. This is perfect for a shell script.
inotify provide the inotify API provides a mechanism for monitoring file system events. If you are willing to write code in Python, C, C++ go with this. If performance is concern select inotify as it is ten time faster than dnotify. HTH
__________________
Vivek Gite Linux Evangelist |
|
|||
|
When I go to put in the first piece of code
Code:
dnotify -C /var/ftp -e echo "File Created" I installed all of the suggested packages from your post, so is there possibly something I am doing wrong? |
|
||||
|
Did any one upload a file in /var/ftp ? For testing try:
PHP Code:
__________________
Vivek Gite Linux Evangelist |
|
|||
|
What I mean is that when I did the following
Code:
# dnotify -C /tmp -e echo "File Created" |
|
|||
|
Thank you for your help, I was able to get this working using the dnotify in background mode. I actually wrote the following shell script to do this:
Code:
#!/bin/bash echo "To:xxxx@xxxx.com" > /var/upload.txt echo "From:xxxx@xxxx.com.com">>/var/upload.txt echo "Subject:blah blah">>/var/upload.txt echo "blah blah message">>/var/upload.txt cat /var/upload.txt|/var/qmail/bin/qmail-inject Last edited by cristobalaz; 18-06-2009 at 05:10 AM. |
|
||||
|
Use the string {} in the command specification is replaced by the name of the directory that was updated.
Code:
dnotify -b -C /var/ftp -e /home/you/yourscript.sh {}
Code:
#!/bin/bash DIR="$1" echo "To:xxxx@xxxx.com" > /var/upload.txt echo "From:xxxx@xxxx.com.com">>/var/upload.txt echo "Subject:blah blah">>/var/upload.txt echo "echo $DIR .... blah blah message">>/var/upload.txt cat /var/upload.txt|/var/qmail/bin/qmail-inject
__________________
Vivek Gite Linux Evangelist |
![]() |
| Tags |
| dnotify , fam , gamin , incron , iwatch , linux , watch file system changes |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linux Shell Script to upload log files to Windows XP based FTP Server | stefanuscyberia | Shell scripting | 6 | 18-11-2009 01:29 PM |
| Vsftpd control upload file size limits | jaysunn | CentOS / RHEL / Fedora | 1 | 06-05-2009 11:29 PM |
| How to Delete a file on 46 th day from the day of creation | knvpavan | Shell scripting | 6 | 12-02-2009 12:07 AM |
| Mail Notification Agent | sumit | Mail Servers | 1 | 25-08-2007 08:05 PM |
| mysql account creation | Linux software | 1 | 28-01-2006 11:17 AM | |