I have an assignment in which I need to create a unix shell using fork(). I’ve got this working correctly. Now I need to check user input to see if it is a valid unix command. If it is not valid (ie its “1035813”) I need to tell the user to enter a valid command.
Is there a way I can get a list of every possible unix command so I can compare the user input with every string in this list? Or is there an easier way to do this?
The appropriate way to do this is:
cdshould probably be a built in command.forkand try toexecit. (execvpis probably what you really want, actually). If that fails, checkerrnoto determine why.Example: