I wrote a simple C program that uses the execl function. What I'm expecting to see after running this program is the output of ps -U myusername.
If writing ps -U myusername in terminal, I get the desired result.
If calling execl("/bin/ps", "/bin/ps", "-U myusername", NULL) I get the following error message error: improper list.
However, if I remove the space from -U myusername, and call the function in the following way: execl("/bin/ps", "/bin/ps", "-Umyusername", NULL), I get the correct result.
Why is this happening and how can I achieve the expected behaviour (this is just a simple example; what I actually want is to let the user input the command and split it in command and arguments and finally call something like execlp("command", "command", "arguments", NULL).)?