Would like to see how others would do this...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Would like to see how others would do this...
# 8  
Old 06-04-2007
Thank you all for the quick responses. I'm going to be working on this later this afternoon and I'll see what I end up with, if wanted I'll share my code when finished.
D
# 9  
Old 06-06-2007
Aigles, I understand your implementation the best but I get:
Unrecognized command: s/therestofyourawkline....

Any ideas?
# 10  
Old 06-06-2007
btw, I just put your code into a script, with the #!/bin/sh disclaimer... I'm just trying to run the code and see how it works, but it doesn't seem to run.
Thanks....
# 11  
Old 06-06-2007
Execute your script with -x option and post the trace please.

Jean-Pierre.
# 12  
Old 06-06-2007
Here it is:
[bcdb/sysadmin/home/dwayne/scripts] ./test.sh
usage=0
time_limit=3
+ echo % h
% h
+ sed -n s/.*\([0-9]\+\)%.*\([0-9][0-9]\):[0-9][0-9]:[0-9][0-9].*/\1
+ \2/;T;p out.txt [[ -gt 0 ]]
./test.sh: [[: not found
+ [[ -gt 3 ]]
./test.sh: [[: not found
Unrecognized command: s/.*\([0-9]\+\)%.*\([0-9][0-9]\):[0-9][0-9]:[0-9][0-9].*/\1 \2/;T;p


Hopefully that helps....
# 13  
Old 06-06-2007
Sorry, a line is missing in my script (read statement) :
Code:
#!/usr/bin/ksh

usage=50
time_limit=3

sed  -n 's/.*\([0-9]\+\)%.*\([0-9][0-9]\):[0-9][0-9]:[0-9][0-9].*/\1 \2/;T;p' out.txt | \
read percentage hours

echo "${percentage}% ${hours}h"

if [[ $percentage -gt $usage ]] ;then
   echo "Disk usage beyond $usage%"
   #send mail
fi

if [[ $hours -gt $time_limit ]] ;then
   echo "Time limit beyond $time_limit hours"
   #send mail
fi

Quote:
+ [[ -gt 3 ]]
./test.sh: [[: not found
The script must be executed under ksh or bash (in that case modify first line).

Jean-Pierre.
# 14  
Old 06-06-2007
I'm trying to modify a sh script so not sure I can do this with your code. I'm trying to just insert some code into an existing bourne shell script.
I'll try ghostdog's code to see if it'll work.... unless you can help me with getting your code into .sh format. thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question