![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| running script in cron - with ssh commands - not working | frustrated1 | Shell Programming and Scripting | 31 | 09-16-2008 10:14 AM |
| error in running shell script in cron | sari | Shell Programming and Scripting | 3 | 04-16-2008 04:09 AM |
| Running a script in cron question | NycUnxer | UNIX for Dummies Questions & Answers | 3 | 01-02-2008 01:22 PM |
| Running a Cron Script only @ Startup Pls Help!! | perk_bud | Shell Programming and Scripting | 3 | 07-17-2007 06:29 AM |
| Running script using cron | ankurgupta | Shell Programming and Scripting | 4 | 12-12-2002 10:41 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I have the following script (trapsize) that checks a file size on my syslog server, and if the file is gt 6g, it will mail an alert to the admin for inspection. The following works like a champ when I execute ./trapsize logged in as root user using bash shell.
Code:
FILESIZE=$(ls -l /opt2/fwsm/fwsm | tr -s " " "\t" | cut -f5)
MAILGROUP="userA@conus.army.mil, userB@conus.army.mil, userC@conus.army.mil"
if [ $FILESIZE -lt 6000000000 ]
then
: # no action required
else
echo "$FILESIZE" | mailx -r userD@post.army.mil -s "File Size Limit of 6g Reached on fwsm" $MAILGROUP
fi
I have created the following in /usr/lib/trapsize for cron, but I can't get it to function. Any advice would be appreciated. Code:
#! /bin/sh
#
# Script will periodically check the log size for the FWSM and notify admin if greater than 6g - jbrannen
#
#
#
FILE=fwsm
FILEPATH=/opt2/fwsm/
FILESIZE=$(ls -l $FILEPATH$FILE | tr -s " " "\t" | cut -f5)
MAILGROUP="userA@conus.army.mil, userB@conus.army.mil, userC@conus.army.mil"
if [ $FILESIZE -lt 6000000000 ]
then
: # no action required
else
echo "$FILESIZE" | mailx -r userD@post.army.mil -s " File Size Limit of 6g reached on fwsm" $MAILGROUP
rm $FILESIZE
fi
trapsize: syntax error at line 10: `FILESIZE=$' unexpected |
|
||||
|
Thanks. The solution was to use the back tics instead of the $( as suggested. The extra space in the example was an illusion produced by the font I guess, because it was not in the actual code.
I do appreciate the help. JB ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|