need help in implementing simple interactive shell in C


 
Thread Tools Search this Thread
Top Forums Programming need help in implementing simple interactive shell in C
# 1  
Old 02-21-2006
Data need help in implementing simple interactive shell in C

hello all,

i hv attached herewith my program to implement a simple interactive shell in C. no matter hw hard I try, I keep getting some errors. i need help - urgently !!

proj1test7.c: In function `parseCommand':
proj1test7.c:102: warning: assignment makes pointer from integer without a cast
proj1test7.c: In function `main':
proj1test7.c:119: warning: passing arg 1 of `parsePath' from
incompatible pointer type
proj1test7.c:125: warning: passing arg 2 of `lookupPath' from
incompatible pointer type

Also, could you please let me know as to how can I compile and run a
program using Emacs? I had been trying to use putty and gcc to compile
my code, but it doesnt recognize strsep() and I am not very comfortable
using strtok in its place. But when I compile it using gcc on the Linux Whitebox, it works fine.

Also, if it does manage to get compiled, I keep getting Segmentation fault!

Please respond ASAP! Thanking you for your time in advance.

- Nix
# 2  
Old 03-15-2006
main thing is forking.

The actual shell on unix or other unix based OS simply forks oneach command input.
So that your programm also get command line input fork() the parent than exec() the command.
Simple example you can find on R.Stevens book Andvanced programming on Unix Environment.
Best of the lucks.
# 3  
Old 03-15-2006
And please note that homework/classwork is against the Rules - thread closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Implementing linked list in shell scripting

Hello Experts, Is it possible to implement linked list in shell scripting? is yes then how can we do it? Any working example is highly appreciated. Thanks in advance. (4 Replies)
Discussion started by: mukulverma2408
4 Replies

2. Shell Programming and Scripting

Implementing Listagg like function in shell

Hi, Basically what I am trying to do is making multiple fields of the same type comma-separated. i.e. for a data like this: B00000 abc B00001 abc,def B00001 ghi B00001 jkl B00002 abc B00002 def B00003 xyz Output should be like: B00000 abc B00001 abc,def,ghi,jkl... (20 Replies)
Discussion started by: prohank
20 Replies

3. Shell Programming and Scripting

Need help implementing a timout in my Shell Script for RHEL6

Hey Guys, My problem: I have a script that will be querying the database every minute to see if it gets a response, the response its querying for is "UP" in a table i made called dbup in the database. Now, I am trying to add the component to implement a timeout if the script does not get a... (2 Replies)
Discussion started by: mo_VERTICASQL
2 Replies

4. UNIX for Dummies Questions & Answers

What is login and interactive shell?

Hi Guys, Excuse if am asking silly Que ... :rolleyes: Please explain me whats difference between login and interactive shell in Linux .. Have googled but still in doubt .. :confused: --Shirish Shukla (4 Replies)
Discussion started by: Shirishlnx
4 Replies

5. Shell Programming and Scripting

Interactive shell - Give answers to shell

Hi, I have a script that calles some other scripts. Those scripts are expecting some inputs. Right no I am typing manually. But now the number of questions from other scripts are too much and I want to give asnwers autimatically. example. Other scripts gives me 2 options 1) joom... (2 Replies)
Discussion started by: microsim
2 Replies

6. Shell Programming and Scripting

Implementing Queue Using Shell scripts

HI I want to implement a control mechanism using Shell scripts .The intention is to have controlled number of jobs running in parallel External process will kickstart 40 jobs in parallel .All the 40 jobs will call the same generic script with different parameter values .But at a... (4 Replies)
Discussion started by: police
4 Replies

7. Homework & Coursework Questions

implementing mkdir, chdir, mv, pwd inside a shell !

1. The problem statement, all variables and given/known data: need to implement mkdir, chdir, mv, pwd given a shell.cpp directory.cpp and some other files this shell missing these commands, and i need to implement them inside the shell 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: evantheking
0 Replies

8. Homework & Coursework Questions

Help with Interactive / Non Interactive Shell script

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (1 Reply)
Discussion started by: rits
1 Replies

9. Programming

Implementing a shell in C

Hi, I am implementing a shell in C, with the following problem... Suppose the shell is invoked from the command line as >> myshell < test.in > test.out 2>&1 I have to execute the commands in test.in and redirect them to test.out How does one detect in the main function that the shell... (1 Reply)
Discussion started by: jacques83
1 Replies

10. Programming

Implementing a shell

I'm implementing a shell in C that supports piping, output redirection, and background processing, and a few other commands. I was wondering how I'd go about implementing the output redirection. So, I'd open a file and I'd fork and execute the command. But how would I get stdout into the file? Any... (10 Replies)
Discussion started by: ununium
10 Replies
Login or Register to Ask a Question