I need a shell script which checks for a file in a particuler folder and should send me a mail if the file of that name is present.
Please help me on this.I am new to shell scripting.
I need a shell script which checks for a file in a particuler folder and should send me a mail if the file of that name is present.
Please help me on this.I am new to shell scripting.
try this:
if [[ -d Foldername ]]; then
mailx -s "the folder is present" emailid@somedomain.com
if [[ -f $your_file ]]; then
mailx -s "$your_file exists..." your_email_address
fi
-d will let you check if a directory exists.
thanks for your reply.suppose we want to send the content of the file as mail means how to do that......
The quick and dirty way may be....
if .... file exists etc etc then
cat $yourfile | mailx -s etc etc etc
fi
Only makes sense if your files is human readable however...
Sorry! I should read the posts thoroughly before posting replies.......
if [[ -f $your_file ]]; then
cat $your_file|mailx -s "$your_file contents..." your_email_address
fi
OR if you want to receive the file as an attachment:
if [[ -f $your_file ]]; then
uuencode $your_file $your_file|mailx -s "$your_file exists..." your_email_address
fi
-d will let you check if a directory exists.