I am making a C program that lists files using execl
to execute the ls
command. If the program is called without any command line arguments, the current directory is listed and if the user specifies a file directory as a command line argument then that directory is listed.
execl("/bin/ls", "ls", NULL);
works fine for listing the current directory
execl(argv[1], "ls", NULL);
is what I'm using for the command line argument. I think this works fine code wise but I can't get the syntax right when I'm making the command line argument:
./a.out /test/ls