Professional Documents
Culture Documents
LAB REPORT 05
IMAD RASHID
DEPARTMENT OF COMPUTER SYSTEM ENGINEERING
17 PWCSE 1541
NAVEED AHMED
DEPARTMENT OF COMPUTER SYSTEM ENGINEERING
17 PWCSE 1507
PRE LAB NOTES
OBJECTIVES
TASK : 01
Implement the cp command.
CODE
#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include <sys/stat.h>
#include<string.h>
if(read(fd1,buf,10000) != -1);
if(write(fd2,buf,strlen(buf))!=-1);
return 0;
1
OUTPUT
BEFORE
AFTER
2
TASK : 02
Implement rm command.
CODE
#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include <sys/stat.h>
#include<string.h>
for(int i=0;i<argc;i++)
{
unlink(argv[i]);
}
printf("Files Deleted Succesfully\n");
return 0;
OUTPUT
BEFORE
3
AFTER
4
TASK : 03
CODE
#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include <sys/stat.h>
#include<string.h>
}
int fd1= open(argv[1],O_RDONLY , S_IROTH );
if(read(fd1,buf,10000) != -1);
if(write(fd2,buf,strlen(buf))!=-1);
unlink(argv[1]);
close(fd2);
return 0;
5
OUTPUT
BEFORE
AFTER