LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-02-2004, 02:27 PM   #1
rags2k
LQ Newbie
 
Registered: Aug 2004
Posts: 7

Rep: Reputation: 0
system("top") in a C program giving problems when the C prg is run by cron


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
 
Old 09-02-2004, 03:25 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,486

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Top has the "-b" option to be use in non interactive mode.

Concerning the execl question, you'll definitely find popen easier to use instead.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple "echo > qbc" cron jobs doesn't run shole Linux - Newbie 3 09-23-2006 02:09 PM
Where to download precompiled bash binaries, such as "time" and "top"? elinuxqs Linux - Newbie 12 11-14-2005 08:36 PM
"mythtv-setup" giving "Session management error: Authentication Rejected" Mitchua Ubuntu 0 10-09-2005 04:32 PM
info to run "cu" command from cron tcore Mandriva 4 03-12-2005 06:03 AM
How can I run the "cu" command under cron? tcore Linux - General 1 03-08-2005 07:45 AM


All times are GMT -5. The time now is 04:03 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration