Operating System - HP-UX
1848248 Members
6807 Online
104022 Solutions
New Discussion

Re: script: top via email

 
SOLVED
Go to solution
Hubert Feller
Advisor

script: top via email

Hi all
I wanted to write a small script to send the output of the top -d 1 - command via email to our unix-inbox for monitoring.
There is no problem to run this script manually, but when i tried to trigger it within crontab it gives me an error. Here the critical line:
/bin/top -d 1 | mailx -s "Output of top-command. Please check!" $EMAIL
and here the error:
Sorry, I need to know a more specific terminal type than 'unknown'.
I added a statement like TERM="hpterm" but id didn't help.
Any ideas?
Thanks for your help

Peter
4 REPLIES 4
Mark Grant
Honored Contributor
Solution

Re: script: top via email

You are sending the output of top to the standard output. There is no terminal attached so this is probably your problem.

Try using the "-f filename" option to "top" to output to a file and then e-mail that file.
Never preceed any demonstration with anything more predictive than "watch this"
Graham Cameron_1
Honored Contributor

Re: script: top via email

Mark's suggestion should work but if you don't want to go via an intemediate file, so should your idea of TERM="hpterm".
Where did you put this ?

It needs to precede the top command, as in
TERM=hpterm /bin/top -d 1 | /usr/bin/mailx -s "Output of top-command. Please check!" $EMAIL

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Hubert Feller
Advisor

Re: script: top via email

Thanks for your help guys

i must have sit on my eyes when I looked at the man-page of the top command. But finally the -f - option solved the problem.

Have a nice weekend

Peter
Hubert Feller
Advisor

Re: script: top via email

Just for info

I found out that the -f - option of the top-command is not documented in HP-UX 10.20 but can be found in HP-UX 11.00. That's why I didn't get it yesterday.