echo output of command and send to email address
Ok below is the code to send the everything works except the following please see code
Code:
#!/bin/bash Code:
"/usr/bin/mailcount" 19 lines, 650 characters |
...and unless you run it as root, you're not going to be able to open anyone else's mail but your own.
|
That code is not particularly clean.
I see Useless Use Of Grep and long chains of text tools that could be replaced by simpler awk versions. Except that said commands are also ill-advisedly parsing ls! Not good. And since this is a bash script, the numerical tests should be using ((..)) instead. I tried to do a bit of re-writing, but I'm stuck over figuring out what two "ls -al /var/spool/mqueue" lines are supposed to produce. I don't have that directory on my system. I tried to reverse engineer them, but it's just not clear to me what they're doing exactly. I can already say, at least, that "sort $5" and "sort $1" won't work properly, unless those are values input when the script is called, since those will be treated as shell positional parameters. sort is not awk. I imagine you want "sort -n k5,5" instead. The proper syntax for tail is also "tail -n 1". The "-1" style is deprecated. But again, I'm sure there are better ways to get that data anyway. Anyway, here's what I came up with far: Code:
#!/bin/bash |
All times are GMT -5. The time now is 05:57 AM. |