If File is present send a mail and Archive


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers If File is present send a mail and Archive
# 1  
Old 05-25-2012
If File is present send a mail and Archive

Hi ,

Please help me with a logic, how can I acheive the below.

I have a directory /eth/Src/, when ever there is a file(or files) created in this directory, (after the file is completely copied to the /eth/Src/ directory) I need to zip all the files and mail the files to a particular email id through the SMTP configured in our server, after the email is succesfully sent , I need to move the file to a archive directory.

I am familiar with send mail in unix through SMTP, what I need is the shell script should keep on checking the /eth/Src/ directory 24/7 and when ever files is created it has to zip and send the mail. please give me some idea on how to acheive this part.

Best Regards,
Wang
# 2  
Old 05-25-2012
Quote:
Originally Posted by wangkc
Hi ,

Please help me with a logic, how can I acheive the below.

I have a directory /eth/Src/, when ever there is a file(or files) created in this directory, (after the file is completely copied to the /eth/Src/ directory) I need to zip all the files and mail the files to a particular email id through the SMTP configured in our server, after the email is succesfully sent , I need to move the file to a archive directory.
The proper way to do this is for the sending process to create them in some other directory on the same partition. Once it finishes sending, it should move them into /etc/Src, where they will appear instantly and whole. You'll never catch a file halfway through uploading.

Is this possible? Or some other sort of signal from the sender? Without that, it's impossible to tell when a file is actually finished. Only the sender really knows that.
# 3  
Old 05-25-2012
In absence of hash/actual file size/record count, One possible way to detect complete download is to check size of downloading file in every 2mins, once the file size stop growing you can assume the file is downloaded.
# 4  
Old 05-25-2012
Corona688 hit it on the head. It's best to have the process create it elsewhere then move it. If that can't happen, then you could try monitoring the process to see when it completes (i'm assuming it's a job that runs at intervals). Once the job has completed, then check for the files, tar and ship them off.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Client was not authenticated to send anonymous mail during MAIL FROM (in reply to MAIL FROM comm

I am having trouble getting mail to work on a red hat server. At first I was getting this message. Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Discussion started by: cokedude
1 Replies

2. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

3. Shell Programming and Scripting

Poll for a file. If not present...Send a alert mail

Dear Experts, I have a requirement where a 3rd party system places a file in my folder.I am running on HP UNIX. I would like to have a unix script which will check for the existence of the file. If yes OK. if the file is not placed then it has to send a mail to couple of emails ids saying that... (3 Replies)
Discussion started by: phani333
3 Replies

4. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

5. Shell Programming and Scripting

Script to send an alert if a file is present in a directory for 10 min

hi, A script which look into a directory and send an alert via a mail. If there is any file exisiting in a directory for more then 10 min. (5 Replies)
Discussion started by: madfox
5 Replies

6. UNIX for Dummies Questions & Answers

How to send file in mail

Hi I want to send out a file that generate 1st of each month that have formate like this 11012008_experience_rate_log.txt Now I have setup a cronjob that usually sent this file in mail like cat /data02/transfer/*_experience_rate_log.txt | mail -s 'PICS EXP RATE Logs' lger@bd.com So how... (3 Replies)
Discussion started by: vishalpatel03
3 Replies

7. AIX

Not able to send out multiple file in mail

Hi All, I have AIX 5.3 server. I am not able to transfer multiple file in mail but I can send one file at a time. the following command I am using to send multiple file mail -s 'PICS EXP RATE Logs' lger@nd.com < /data02/transfer/*_experience_rate_log.txt but this not working. i can send... (2 Replies)
Discussion started by: vishalpatel03
2 Replies

8. UNIX for Advanced & Expert Users

how to send file as attachment with mail ?

hello , i m new to linux/unix , well in my college their is linux server to which we all (i and my frnds) login , we can send mail to each other through command "mail" . but any one can tell me how can i attached a binary file with mail. we are using red hat , "pine ", "mailx" , all... (2 Replies)
Discussion started by: alert_every1
2 Replies

9. Shell Programming and Scripting

Pull E-mail address from file, send e-mail

Hello, I am new to perl and need to create a script that will read a file and pull a name from the file and send e-mail. How can I use the following awk statement in a perl script? grep UNIXadmins /root/mail.conf | awk '{ print $2}' and use the output to send a e-mail. Any help would... (1 Reply)
Discussion started by: DC Heard
1 Replies

10. UNIX for Dummies Questions & Answers

Send text file to mail

I have a utility that opens a telnet session and allows me to execute commands through a script. The utility allows me to output to a text file whatever is outputted to screen. This utility runs from a DOS prompt in Windows 95/98, NT or 2000. How can I mail text file this to a certain user. I... (2 Replies)
Discussion started by: petrosi
2 Replies
Login or Register to Ask a Question