UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 29th, 2004, 04:29 AM
drina drina is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 5 drina User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
need help with simple shell program

i am have a problem with my program i don't know how to correct my errors. here's the program
and errors:

#include <stdio.h>
#include <iostream.h>
#include <sys/types.h>
#include <sys/wait.h>

void parse(char *line, char **argv)
{
argv[0] = (char *)malloc (100);
argv[1] = (char *)malloc (100);
argv[2] = NULL;
int counter = 0;
while(*line != '\0')
{
char *temp_val = argv[counter];
while((*line != '')&&(*line != '\t')&&(*line != '\n')&&(*line != '\0'))
{
*(temp_val++) = *(line++);
}
*temp_val = '\0';
counter ++;
while((*line == '' || *line == '\t' || *line == '\n')&&(*line != '\0'))
{
line++;
}
}
}

int main()
{
char line[100];
char *argv[100];
while(1)
{
cin.getline(line,100);
parse(line, argv);
if strcmp(argv[0], "exit")==0) exit (0);
{ int childpid;
childpid = fork();
if(childpid > 0)
{
waitpid(childpid,0,0);
}
if (childpid ==0)
{
execvp(argv[0],argv);
}
}
return 0;
}

parse error before '(' token that does this mean?

Reply With Quote
  #2  
Old September 29th, 2004, 11:22 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,089 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 3 h 40 m 34 sec
Reputation Power: 9
that 'simple shell program' will mostly called a 'c-program'
(i can|will not read it)

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > need help with simple shell program


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway