system("top") in a C program giving problems when the C prg is run by cron in Red hat linux 9

Raghudev Ramaiah raghudevramaiah at yahoo.com
Thu Sep 2 19:21:31 UTC 2004


hi,

i have used something like
system("top -p 3211 -p 3232 -n 1 > log.txt ");
in my c program. The C prgm is running well when i run it from inside a terminal. 
I have included the executable of this c program in the crontab file for root.
But it is giving unknown TERM VT100 error then and top command is not run successfully, i.e, no output. So I set $TERM = vt100 and $TERMCAP= the termcap file for vt100
i tried setting $TERM = xterm and $TERM = linux with their corresponding values(paths of terminfo files) in $TERMCAP. But the tcgetattr() fn returned error. Now How can I get this program to work when its executed automatically by cron daemon. 

I tried using execl() instead of system() API   to execute the top command inside the C program. But I dont know how to write the  output of the thus executed top command to a file. Please let me know how to do this.

Please let me know the solution wither way.

Thanks and Regards
Raghu



		
---------------------------------
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.


More information about the redhat-list mailing list