#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc,char** argv){

	int bytes = 1024;
	char buf[1024];
	int fd=0;

	if (argc==1) {
   		while(1){
       		int b = read(STDIN_FILENO,buf,bytes);  // read till newline
       		if(b<=0) break;
       		write(STDOUT_FILENO,buf,b);
   		}
	}
	else if(argc==2) {
		close(STDIN_FILENO);
		fd = open(argv[1],O_RDONLY);
		execl("./mycat", "mycat", NULL);
	}
	return 0;
}
