Click here to Skip to main content
13,139,114 members (62,897 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have the following assignment but i have no idea where to start.pls help at least tell me what kind of material i sld read.

write a program doit that takes another command as an argument and executes that command. For instance, executing:
% doit cat /etc/motd
would invoke the cat command on the file /etc/motd, which will print the current “message of the day.” After execution of the specified command has completed, doit should display statistics that show some of the system resources the command used.

Posted 1-Oct-12 20:38pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The first point is almost trivial: your program's main function (assuming you are using C), namely:
int main(int argc, char* argv[])

receives the command to execute (e.g. "cat") as arg[1] and its parameters as arg[2], arg[3], etc... A very simple implementation would use the system[^] call to execute the command.

The second point might be implemented, I guess, accessing the /proc/<pid>/stat[^] file.
mimi from Unknown 2-Oct-12 3:50am
yeah tnx for ur replay but i am a beginner to this and i am having a hard time tring to understand what u meant.
I was reading a bash scripting books to help me with this assignment.I kinda felt like i am not getting closer to the solution so ...... what sld i read to understand this...pls help!!!!


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100