fonet
fonet

Reputation: 1

insert unknown command to execvp()

hi if i'm passing an unknown command to execvp i'm getting this error in the errno : "no such file or directory" when i should get this error: "command not found"

how can i get the second error?

Upvotes: 0

Views: 997

Answers (2)

Anomie
Anomie

Reputation: 94834

There is no "command not found" error that can be returned from execvp. The closest is ENOENT, which means that the file specified (or its interpreter, or a required dynamic library) was not found.

If you want, your program could print out "command not found" rather than the text returned by strerror.

Upvotes: 1

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272667

Because "command not found" does not correspond to a standard error code (see e.g. http://linux.die.net/man/3/errno).

Upvotes: 1

Related Questions