PDA

View Full Version : CLI help


hifza
October 26th, 2009, 09:19 AM
im completely new to linux. i hav the following task to complete. i managed to do this by adding aliases to the .bashrc file and by changng the PS format from there. but the teacher wants it all to be done in the form of a c code. plz help.

TASK:
When the process starts, a prompt of following format should appear on the Terminal/Konsole:


[time] user@host: working_dir $


e.g., [12:34] ali@myPC: /home/ali $


Students are required to implement three possible operations. These include

When the user enters “list”, a listing of all the contents of the working directory should be displayed (similar to the 'ls' program in Linux)
When the user enters “create file_name content”, the process should
Create a file called file_name in the current directory
Write the string “content” into the newly created file

The process should terminate/end when the user enters "quit"

gunksta
October 26th, 2009, 10:20 AM
I think you need to clarify the assignment. Are you trying to implement a simple shell (like bash, csh, etc.), pimp your bash prompt, or are you writing a program in C that will edit your PS settings?

These are very different projects.

The Ubuntu forums also have a section dedicated to programming. If you need to do much programming in C, I would go there for help. I don't know how many of the folks who frequent this forum program in C. I'll admit that I haven't written a single line of C code since college and with every passing day, those memories get a little fuzzier.

But, don't ask folks to tell you how to do it. If it's an assignment, you're better off learning how to do things yourself. That being said, there are some wickedly smart/wise souls around here and they can definitely point you in the right direction and make sure you read the right materials so you don't waste your time. Just be careful with how you ask your question.

hifza
October 26th, 2009, 10:38 AM
i have to make my own shell which performs all of these functions. the functions have to be implemented by a c code.

and i did try on my own, all i could figure out was to do this with aliases...and that's not what was required. that's why i'm looking for help.
thank you, anyway.

samden
October 27th, 2009, 10:59 PM
As Gunksta said, post in the programming section of the forum and you should receive far more help than you can here.
http://ubuntuforums.org/forumdisplay.php?f=310