implemenation of cwd()

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers implemenation of cwd()
# 1  
Old 09-20-2007
implemenation of cwd()

i'm writing my own shell and implementing a few unix commands.
I'm using the readline() for input and strtk() to tokenize it. I need to implement the cwd command as an option in the shell..
Here's the layout :

while true do
Read a line of input using readline()
tokenize the input
switch token[0] do
case cd
change to specified directory in token[1]
case pwd
print the current working directory
.....and so on

My C skills are a bit rusty...could use all the help i can get
Thanks in advance
# 2  
Old 09-20-2007
chdir() changes directory

fgets(<string>, <size in bytes>, stdin) reads a line from the terminal - one way of many ways to do this - there is no readline in ANSI C

getcwd() gives you the current directory you are in
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

#$ -cwd #what does this mean?

When I want to specify the current working directory (-cwd) why do I need a # followed by a $? What does the combo of #$ do? Thanks. (1 Reply)
Discussion started by: rebazon
1 Replies

2. Shell Programming and Scripting

CWD in prompt only showing the directory when set

Hi Gurus, I am working in tcsh and i set the prompt with this. set prompt = "$cwd>" But I see teh prompt only gets reflected with the directory where I set the prompt. After i cd to another directory it still shows the old directory. Please advise (1 Reply)
Discussion started by: kinny
1 Replies

3. UNIX for Dummies Questions & Answers

CWD as Prompt

I need a one line command called cd (must also still function as cd) and will allow the prompt to change to the cwd. All I can figure out is to change the .cshrc but there must be an easier way in a one line command no? (1 Reply)
Discussion started by: petter_uk
1 Replies

4. UNIX for Dummies Questions & Answers


Hello ! How can I see my current working directory on the bar of my "dtterm" window (I use CDE). any ideas ? thnx, GISMO (1 Reply)
Discussion started by: Gismo
1 Replies
Login or Register to Ask a Question