|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Shell script help
I need to send out an email when the return of an ls | wc -l command returns a number > 500 . here is what i have but it' not working, any help would be appreciated:
#!/bin/ksh set test_records = expr ` exec ls /usr/local/test/failures | wc -l ` echo "$test_records" if [ "$test_records" > 0 ] then echo "help me $test_records" mail -s "DATAFEED" 14679@email.com exit fi exit |
|
#2
|
|||
|
|||
|
Code:
#!/bin/ksh test_records = `ls /usr/local/test/failures | wc -l ` if [[ $test_records -gt 500 ]] ; then echo "Too many test filures: $test_records" | /usr/bin/mailx -s "DATAFEED" 14679@email.com fi exit |
|
#3
|
|||
|
|||
|
Not sure if relevant or not, but I'd use ls -1 (lists 1 file per line, for the wc -l (line count) or wc -w (for word count)
|
|
#4
|
||||
|
||||
|
I'd leave out the ls all together, because ls /usr/local/test/failures | wc -l will only ever return 1, unless you were to use a wildcard.
![]() From the looks of things, /usr/local/test/failures is a script of a program of some description. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Shell script help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|