Part 1
The purpose of this part 1 is to give you practice in the use of following UNIX system calls other than using the
command line arguments.
• int read(int fd, char* buff, int len)
• int write(int fd, char* buff, int len)
• int open(const char* filename, int flags)
• int close(fd)
You need to write two programs.
• The first program encipher.c will read one file name from the command prompt. It will open the file, read its
contents, encrypt its contents using some encryption algorithm and write the encrypted contents in another file. If
the file name is file1.txt then the new encrypted file name should be file1.cipher. The new encrypted file should
be created in the present working directory.
• The second program decipher.c will read one file name from the command prompt, which should be file1.cipher
(a file already encrypted by the first program). It will open the file, read its contents, decrypt its contents using
appropriate decryption algorithm and write the contents in another file. If the file name is file1.cipher then the
new decrypted file name should be file1.txt. The new decrypted file should be created in the present working
directory.
Part 2
The purpose of this part is to give you practice in the use of following UNIX system calls.
• int fork( )
• wait(&status)
• exit(n)
• int execlp(const char* progname, const char* arg0, const char* arg1, … const char* argn, ‘\0’)
• int pipe(int pipefd[2])
You need to write a program that will create/fork a child. The parent program should receive an integer array
via command line arguments send that integer array to the child program using any of the IPC tools discussed in class
(preferably pipe). The child program should sum up the contents of the array and will return the sum to the parent. The
parent will finally display the sum in the file having file descriptor 1.