LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 04-09-2002, 09:39 AM   #1
daviest11
LQ Newbie
 
Registered: Apr 2002
Location: Bristol
Posts: 4

Rep: Reputation: 0
Question Re-coding basic shell commands in C


Hi All,

I'm trying to write my own shell for linux - a small part of a major assignment. Using C I've got to write simple versions of the following shell commands:
ls [-al]
pwd
cd
ps [-A]
and kill

Could anybody help? If not, does anybody know any sites that might have simple versions of these functions. It'd save my life!
 
Old 04-09-2002, 11:10 AM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Sounds like a good assignment.

None of those commands should be that difficult to write. I have written some of these commands in part on this site, if you spend some time searching you may find them.

I'd suggest spending you time looking through a good book: "Advanced Programming in the UNIX Environment" by Stevens. It's an excellent book and will have examples of how to do most of those commands.
 
Old 04-11-2002, 10:25 AM   #3
daviest11
LQ Newbie
 
Registered: Apr 2002
Location: Bristol
Posts: 4

Original Poster
Rep: Reputation: 0
Cheers for that.
I've not got much time to get this done and I'm fairly new to all this OS stuff. I've written a changedir script - how do I apply it to the current shell rather than the one in which it is executed (i think that makes sense)??
I'm also well stuck on what system calls would be approriate for the ps command,

Thanks again.
Tom
 
Old 04-11-2002, 11:50 AM   #4
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
For ps take a look at the source code for top. It looks like they read from the /proc filesystem. There is a directory for each pid in /proc. In the pid directories there is a stats file. These are the process stats.
 
  


Reply



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
Basic shell commands pppaaarrrkkk Linux - Newbie 7 02-05-2007 07:31 AM
Shell colour coding linmix Linux - Newbie 6 01-30-2005 12:48 PM
Coding a Shell Smooth Programming 4 09-19-2003 12:59 AM
Shell and file/directory color coding? l0f33t Linux - General 9 08-07-2003 10:19 PM
Basic Shell commands and Linux Administration Gear_freak2000 Linux - Newbie 6 06-01-2003 05:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:27 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration