Results 1 to 10 of 12
I am new to linux, I have an assignment for my operating system class, I don't know where to start. The question is
Create a Linux shell (in other words, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-14-2012 #1Just Joined!
- Join Date
- Oct 2012
- Posts
- 4
Linux programmin help
I am new to linux, I have an assignment for my operating system class, I don't know where to start. The question is
Create a Linux shell (in other words, write a C program) that will recursively prompt for input from the user. The shell should prompt as
yourRollNumber-currentDirectoryName>
For instance if the current directory is /home/OS and your roll number is 1234567, the shell should prompt as:
1234567-OS>
any help in this regard will be highly appreciated. Let me know where to start Please..............
- 10-14-2012 #2Linux Newbie
- Join Date
- Apr 2012
- Posts
- 112
Have a look at this link, it might help
- 10-15-2012 #3Just Joined!
- Join Date
- Oct 2012
- Posts
- 4
[
well thanks, I am not looking for how to change the outlook. I am looking for procedures running background using command ls, pwd etc. I have to write a program in c, that prompt for user input and show your working directory, thanks
- 10-15-2012 #4Just Joined!
- Join Date
- May 2012
- Posts
- 43
Still not entirely sure what your question is, but here's how to get the current working dir.
Not sure what yourRollNumber is meant to be or how it's meant to be obtained.Code:${PWD##*/}
- 10-15-2012 #5
Hello and Welcome!
I'm not exactly a pro at writing scripts. But maybe if you post what you have started with, others may be able to chime in with some pointers for you.
Other than that, the best that we may be able to provide is a few links to sites similar to the one posted above.Jay
New users, read this first.
New Member FAQ
Registered Linux User #463940
I do not respond to Private Messages asking for Linux help. Please, keep it on the public boards.
- 10-15-2012 #6Linux Newbie
- Join Date
- Apr 2012
- Posts
- 112
There is a function called getcwd that will do what you want, i.e. get the current working directory.
Is the roll number the user name in the system?
If it is you could try this:
printf("%s@shell:%s$", getenv("USER"),getenv("PWD"))
from here
or use the getuid function.
Edit.
As an aside you learn a lot more from trying that from somebody giving you the answer.
I vaguely remembered the getcwd function from back in the day, so I had to do a bit of research [Googling to you and me] to confirm what it was called and during that search I stumbled upon the stackoverflow post.
You have to ask yourself, what are you trying to do? Learn or pass your module/class
I had the same attitude when I was at uni and it was the wrong attitude. I finished with a good Physics degree and hardly any knowledge. If you really want to learn, then you are going to have to put the time in.
sorry about the rant [monday morning, I is Cranky
]
Last edited by manyrootsofallevil; 10-15-2012 at 07:06 AM.
- 10-15-2012 #7Just Joined!
- Join Date
- Oct 2012
- Posts
- 4
Thanks, everyone for your time, I am still no getting the answer. I looking for procedures or source code that run these commands. Anyways thanks..............
- 10-15-2012 #8Linux Newbie
- Join Date
- Apr 2012
- Posts
- 112
I think you'll find what you want here
- 10-15-2012 #9
If you are completely stuck on how to start an assignment the best person to ask for help is your tutor. Not only will that help you with the assignment, it will help your tutor tailor the class material so it is more useful for you.
It is against the rules here to do someone's homework for them so you are unlikely to get a complete solution. However, posting what you have done so far and asking a specific question about it will usually get you pointed in the right direction.If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.
The Fifth Continent reborn
- 10-15-2012 #10Just Joined!
- Join Date
- Oct 2012
- Posts
- 4
thanks for your advice, i am not asking for homework, i am just asking about the source code for command like ls, pwd etc...
ayways i got your point. tnx


1Likes
Reply With Quote

