Skip to content
This repository has been archived by the owner on Nov 27, 2019. It is now read-only.

Latest commit

 

History

History

2-5-Aug

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Lab 2: August-5

Question:

A file contains a list of commands, one per each line, with variable number of arguments.
Write a C program to read each command and its arguments and execute them.
The program terminates when all the commands are completed.

E.g., Sample Commands in the file:

ls -al
wc prog.c (replace with your program name)
ping www.google.com
whoami
touch newfile.c
cp prog.c newfile.c
diff prog.c newfile.c
rm prog.c
gcc newfile.c -o newfile.out

To compile: gcc Prgm-1.c -o prgm-1-out

To execute: ./prgm-1-out test-commands

Note: There should be a \n(newline, not literally) at the end of the file:

ls -al
ping
whoami
*\n*

for the program to work