Re: How to use a shell command in an application?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 10, 2005 at 04:31:39 +0300, Yasmine Habib wrote:
> How can i use a shell command inside a program or application? in
> other words, i am writing a small scheduler that needs to get the
> current cpu usage/utliization of a processor at a certain time. using
> "top", "free", "vmstat" provide me with required information but just
> as a display when used as a shell command. i need the code to be
> written inside my scheduler.

In the subject, you are asking the wrong question! You don't want to use
shell commands, that is invoke other application, in your application.
You really want to get the cpu and memory usage statistics and presume
a solution, that is wrong. You don't want to invoke top, free and vmstat
-- you want to read the information from the source they do. Now, that
source is in procfs (the thing usually mounted on /proc).

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@xxxxxx>

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux