> cin>>command;
Well you have to break the command up into words, like "ls", "-la"
Ok, so there's another problem, which is cin only reads one word at a time, so how about
cin.getline( command );
Right, having got a string of space separated words, you need to split them up into words
For example
char *str = command.c_str(); // is this how you get at the string within a c++ string object?
Then to actually break out the words
Code:
char *p;
int i = 0;
for ( p = strtok( str, " " ); p != NULL ; p = strtok( NULL, " " ) ) {
line[i++] = p;
}
line[i] = NULL;
Then it should be
execve("/bin/ls", line, NULL);
Or perhaps
execve(line[0], line, NULL);
One more thing
if (pid=fork())
Should be
if ( (pid=fork()) != 0 )
In this example, it doesn't much matter, but you will be badly burnt in future if you type = when you meant ==