|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Email Command Error
Hi ,
i am very new unix i need a script which should check for the size of the file and if it is greater than zero ,than i have copy the contain of the file (the file we have checked the size) as body . Thanks Anuddep |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
#!/bin/somesh # arg 1 is the filename SM="/usr/lib/sendmail -t -i " fname="$1" [ "$fname" = "" ] && echo "usage:$0 file" >&2 && exit 2 # test size of file using -s = size > 0 # -f test only file, size 0 is also true [ ! -s "$fname" ] && exit 1 $SM <<EOF From: myemail@mydomain To: someemail@somedomain Subject: File $fname include something $(<$fname) -myname- EOF |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Email Command Error
@kshji ,
kindly can you please explain the script |
|
#4
|
||||
|
||||
|
Using mailx
Code:
FILE=$1 # Accept file name as argument. [[ -s "$FILE" ]] && mailx -s "Subject" user@host.com < $FILE # Check file size if > 0, then send mail |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
I prefer and recommend mailx. I hope you don't need further explanation of bipinajith's script.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using top command to email if process is exceeding 25% and sending an email alert if so | jay02 | Shell Programming and Scripting | 8 | 03-02-2012 11:36 AM |
| How to create a script that will email once there is an error? | rymnd_12345 | UNIX for Dummies Questions & Answers | 2 | 12-26-2011 11:48 PM |
| Error while sending email from solaris | Danish Shakil | Shell Programming and Scripting | 0 | 03-05-2009 08:39 AM |
| VIP membership email error | DeepakS | Post Here to Contact Site Administrators and Moderators | 1 | 12-16-2008 02:54 PM |
| Text File error in email | mgirinath | Shell Programming and Scripting | 3 | 07-12-2006 06:10 AM |
|
|