Solved

Unix script command Find -exec | mailx

Posted on 2010-08-31
5
875 Views
Last Modified: 2013-11-17
I want to send an email message to a user or distribution list (already created) if the file is older than sixty minutes.  Here is the command I am using.  I get an error "expression term lacks a required parameter.  I would like to get this command working, but will welcome other suggestions for tackling the same requirement.

find /fdmdev/proedi/temp -name 'PROEDI*.CHK' -amin +60 -exec echo "Found" {} | mailx -s "Error" -c shapley ";"
0
Comment
Question by:eshapley
  • 3
5 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
Comment Utility
Hi,

the error message is due to the missing semicolon following the "exec" construct. The statements following the pip" are not part of exec!
So it should be like this:

find /fdmdev/proedi/temp -name 'PROEDI*.CHK' -amin +60 -exec echo "Found" {} ";" | mailx -s "Error" -c shapley

wmp

0
 

Author Closing Comment

by:eshapley
Comment Utility
Thank you !!
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
Just saw it - could it be that your mailx statement is missing a recipient? And if it's really AIX - "-c" is not a valid flag for IBM's mailx!
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
Sorry, the last part should read "-c alone is not a valid flag for IBM's mailx"
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
Note that amin +60 (or atime) won't necessarily tell you if a file is older than 60 minutes, because if you view the file, the atime will be reset.

Better to use mmin
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now