/* * Assignment Two * * Write a C program that accepts up to 255 arguments and * displays these arguments individually, one per line. * Now have the program run a new program specified on the * command line. Use "man execl" to see the description * of the system service "exec." Be sure to specify the * complete path (/bin/ls) to run the desired program. * * DO NOT HAND IN THE EXAMPLE PROGRAM. You must submit * a working derivative of the example program. * * For more information on other forms of the exec() * service, use the Unix "man" command and read about exec * in section 3 with the command "man 3 exec" * * Use the script program to show the program source code, * its compilation, and run time behavior. Show success * and failure of executing the command argument. */ #include /* Defines printf() and other fxxxxx() I/O services */ #include /* Defines exec() family of services */ main (int argc, char *argv[], char *envp[]) { register char **p; for (p = argv; *p ; p++) { printf ("%s\n", *p); } if (execv (argv[1], &argv[1])) /* -1 return means error */ printf ("Cannot find file\n"); }