473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

System programming - creating a shell

Hi,
My teacher gave me an assignment to create a shell using ANSI C and
system calls. The shell is going to be very simple that can handle IO
redirection and pipes.

so far I create a program that prompts user and read commands using
scanf and then save this command in a string called cmd. then it uses
fork to create a child process and then execute the command using
execlp,my teacher said use execvp but it was giving me error. i.e when
I use
execvp(cmd,(char *)0) /* cmd is char cmd[200] */
it gives me error.

can any one explain why.
Nov 14 '05 #1
4 11001

"Excluded_Middle" <sf****@hotmail.com> wrote in message
news:5f**************************@posting.google.c om...
Hi,
My teacher gave me an assignment to create a shell using ANSI C and
system calls. The shell is going to be very simple that can handle IO
redirection and pipes.

so far I create a program that prompts user and read commands using
scanf and then save this command in a string called cmd. then it uses
fork to create a child process and then execute the command using
execlp,my teacher said use execvp but it was giving me error. i.e when
I use
execvp(cmd,(char *)0) /* cmd is char cmd[200] */
it gives me error.

can any one explain why.


You called execvp wrong. [hint check the man pages]

Also seems you're posting from rogers. You wouldn't happen to be going to
Algonquin College would ya? Tisk tisk. Cheater.

Tom
Nov 14 '05 #2
On 3 Feb 2004 20:48:45 -0800, sf****@hotmail.com (Excluded_Middle)
wrote in comp.lang.c:
Hi,
My teacher gave me an assignment to create a shell using ANSI C and
system calls. The shell is going to be very simple that can handle IO
redirection and pipes.
Either you or your teacher is insufficiently knowledgable. It is
literally not possible to perform IO redirection or pipes in ANSI C.
On top of that, system calls are non-portable and not part of ANSI C
either. If your teacher literally told you to use those things in
ANSI C, your teacher does not know C and is unqualified to be teaching
the subject.
so far I create a program that prompts user and read commands using
scanf and then save this command in a string called cmd. then it uses
fork to create a child process and then execute the command using
execlp,my teacher said use execvp but it was giving me error. i.e when
I use
There are no such thing as "fork", "child process", or "execvp" in
ANSI C either. If your compiler supplies such things, they are
non-standard extensions it supplies, not part of C.
execvp(cmd,(char *)0) /* cmd is char cmd[200] */
it gives me error.

can any one explain why.


Nobody here will. We discuss the C language, not non-standard
extensions. You need to ask in a group that supports your particular
compiler/operating system combination.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #3
Jack Klein wrote:
On 3 Feb 2004 20:48:45 -0800, sf****@hotmail.com (Excluded_Middle)
wrote in comp.lang.c:
Hi,
My teacher gave me an assignment to create a shell using ANSI C and
system calls. The shell is going to be very simple that can handle IO
redirection and pipes.
Either you or your teacher is insufficiently knowledgable. It is
literally not possible to perform IO redirection or pipes in ANSI C.


You can, however, fake them if you're writing a shell.
On top of that, system calls are non-portable and not part of ANSI C
either.


They don't have to be, if you just pass them on to a local command processor
and rely on the user to know what's legal for that command processor and
what isn't.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #4
Jack Klein <ja*******@spamcop.net> spoke thus:
My teacher gave me an assignment to create a shell using ANSI C and
system calls.
Either you or your teacher is insufficiently knowledgable.


The "and system calls" indicates that the assignment is both
well-defined and off-topic, at least as far as the system calls are
concerned.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: none | last post by:
Hello all, I wrote a shell program a few years ago in VB6 that needs to be modified. The problem I have is this: The SysAdmin uses this shell in place of Explorer, so there is no taskbar. When...
32
by: David Brown | last post by:
Hello. I recently came across a free operating system called Unununium (or something like that) and it was developed in Python and Assembly. Now, I have been looking for a way to make an...
9
by: Baza | last post by:
Am I right in thinking that >>>print "\a" should sound the system, 'bell'? B -- Computer says, 'no'
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
4
by: Ping | last post by:
Hi, All, How to create a Shortcut File by programming in C++? To use whitch function or Windows API? Thinks.
1
by: §iD` | last post by:
Hi, I would like to create a file system virtual directory which should be accessible by Explorer and by application from the standard path (ex. c:\virtual_directory). I would like to be able to...
3
by: Patrick Dugan | last post by:
I am using VS2005 (vb) and I have a program that starts when Windows boots up. Occasionally the icon that should appear in the system tray does not show up. The program is still running in memory...
5
by: Henaro | last post by:
Hello~ I am having trouble setting environment variables in C++ on win32. The code that is not working is: char prxy; char pf_cmd1 = "set http_proxy="; ....
1
by: qilin | last post by:
I have perl program which use system() to call another c program meanwhile the c program also use system() to execute a linux command line ....but not sure why it doesn't work. yes, the perl...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.