/
myShell.c
executable file
·991 lines (862 loc) · 22.1 KB
/
myShell.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/utsname.h> //uname
#include <sys/times.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <dirent.h>
#include <sys/stat.h>
#include <utime.h>
#include <fcntl.h>
#define MAX 100
char cmdline[MAX];
char* args[MAX];
char check[MAX][MAX] = {"cat", "cd", "cp", "date", "head", "ls", "ll", "ln", "ld", "mkdir", "mv", "pwd", "rm", "rmdir", "tail", "time", "touch", "uname"};
/*---------------------- `cat` command ------------------------*/
int mycat(int argc, char** argv)
{
char end;
char wr = '>';
char ovwr[] = ">>";
char buf[MAX];
char* f1, f2;
int fp1, fp2;
int nb=0;
//echo to command line directly
if(argc == 1)
{
printf("Type 'end' to terminate the program\n");
while(strcmp(buf, "end") != 0)
{
gets(buf);
puts(buf);
}
}
else if(argc == 2)
{
//file already exists
if(access(argv[1],F_OK|R_OK) == 0)
{
fp1 = open(argv[1], O_RDONLY);
//file opened successfully
if(fp1 != -1)
{
lseek(fp1, SEEK_SET, 0);
//read successfully
while((nb = read(fp1, buf, MAX)) > 0)
{
//write to output terminal succesfully
write(1, buf, nb);
}
}
else
perror("File error");
}
else
perror("Access error");
}
//read from terminal and write to file
else if(argc == 3)
{
//overwrite option used
if(strcmp(argv[1],"-o") == 0)
{
//O_TRUNC removes existing file content, O_WRONLY opens file for writing purpose only
fp1 = open(argv[2], O_TRUNC |O_WRONLY);
if(fp1 != -1)
{
//read successfully
while((nb = read(0, buf, MAX)) > 0)
{
//write to output terminal succesfully
write(fp1, buf, nb);
}
close(fp1);
}
}
else if(strcmp(argv[1], "-w") == 0)
{
//O_APPEND appends to existing file content, O_WRONLY opens file for writing purpose only
fp1 = open(argv[2], O_WRONLY | O_APPEND);
if(fp1 != -1)
{
//read from terminal
while((nb = read(0, buf, MAX)) > 0)
{
write(fp1, buf, nb);
}
close(fp1);
}
}
}
//read from file 1 and write to file 2
else if(argc == 4)
{
//3rd argument is the option and file 1 exists
if((strcmp(argv[2], "-o") == 0) && (access(argv[1], F_OK|R_OK) == 0))
{
fp1 = open(argv[1], O_RDONLY);
//if file 2 exists, truncate and open else create file 2 and open
fp2 = open(argv[3], O_CREAT | O_TRUNC | O_WRONLY);
if(fp2 != -1)
{
//read from file 1 successfully
while((nb = read(fp1, buf, MAX)) > 0)
{
//write to file 2 successfully
write(fp2, buf, nb);
}
close(fp1);
close(fp2);
return 0;
}
}
}
else
{
printf("Incorrect usage:\n<command> | <command> <filename> | <command> -o <filename> | <command -w <filename> | <command> <filename_1> -o <filename_2>\n");
return 0;
}
return 0;
}
/*---------------------- end of `cat` command ------------------------*/
/*-------------------------- `cd` command -----------------------*/
int mycd(int argc, char** argv)
{
//valid number of arguments
if(argc==2)
{
//chdir executed successfully
if(chdir(argv[1])==0)
{
printf("Directory changed to %s", argv[1]);
system("pwd");
printf("\n");
}
//error
else
{
perror("Directory change error");
return -1;
}
}
//invalid number of arguments
else
{
printf("Incorrect number of arguments : <command> <dir_name>\n");
return -1;
}
return 0;
}
/*---------------------- end of `cd` command ------------------*/
/*------------------ `cp` command ------------------*/
int mycp(int argc, char** argv)
{
char* buf[MAX];
int fd1, fd2;
//valid number of arguments
if(argc==3)
{
fd1=open(argv[1],O_RDONLY);
//check if file is opened
if(fd1==-1)
{
perror("File creation error");
return 99;
}
//file created : file descriptor returned
else
{
fd2=open(argv[2],O_WRONLY|O_CREAT,0777);
//if file is created
if(fd2!=-1)
{
if(read(fd1,buf,MAX)!=-1)
{
if(write(fd2,buf,MAX)!=-1)
{
printf("File %s copied to %s\n",argv[1],argv[2]);
return 0;
}
}
//file had read/write errors; hence delete the 2nd file created
else
{
if(!unlink(argv[2]))
{
return 99;
}
}
}
}
}
//invalid number of arguments
else
{
printf("Error: Enter command followed by file to be copied and destination file\n");
return 100;
}
}
/*---------------------- end of `cp` command ------------------*/
/*---------------------- `date` command ------------------*/
int mydate(int argc, char** argv)
{
const time_t* timv;
//get local date & time
timv = time(0);
while(true)
{
//get the current time in string format
printf("%s",ctime(&timv));
break;
}
return 0;
}
/*---------------------- end of `date` command ------------------*/
/*---------------------- `head` command ------------------*/
int myhead(int argc, char** argv)
{
FILE* fp;
int fd, n, count=0;
char line [MAX];
//number of lines to be printed are specified
if(argc == 3)
{
n = atoi(argv[1]);
fp = fopen(argv[2], "r");
}
//number of lines not specified, take 10 by default
else if(argc == 2)
{
n = 10;
fp = fopen(argv[1], "r");
}
else
{
printf("Incorrect usage : <command> <filename> | <command> <num_lines> <filename>\n");
return -1;
}
if(fp == NULL)
{
perror("File error");
return -2;
}
//print till counter variable 'count' == n
while(fgets(line, sizeof line ,fp)!= NULL)
{
if(count == n)
break;
fprintf(stdout,"%s",line); //print the file contents on stdout
count++;
}
fclose(fp);
return 0;
}
/*---------------------- end of `head` command ------------------*/
/*---------------------- `ls` command ------------------*/
/* ls option to list all the files in the current directory */
int myls(int argc, char** argv)
{
char choice[] = "- i";
struct dirent **list;
int i,j,n;
int check = 0;
if(argc > 3)
{
printf("Incorrect usage : <command> | <command> <dirname>\n");
return -1;
}
//if only command is given, assume current directory to be listed
if(argc == 1)
{
argv[1] = ".";
}
if(argc == 2 && (strcmp(argv[1], choice)==0))
check = 1;
//argv[1] - pathname of directory
//&list - pointer address of the sorted entries list
//0 indicates all values are selected to be sorted
//4th argument is the compar argument, if NULL array is unsorted
//alphasort - takes 2 arguments at a time and sorts them within the array
//returns number of entries in the array
if((n=scandir(argv[1], &list, 0, alphasort)) != -1)
{
//files sorted successfully
for (i = 0; i < n; i++)
{
//filename is printed in row and column format
if(check)
printf("%ld\t", list[i]->d_ino);
printf("%s\n", list[i]->d_name);
free(list[i]);
}
printf("Number of files : %d\n", n);
free(list);
}
return 0;
}
/*---------------------- end of `ls` command ------------------*/
/*
struct dirent {
ino_t d_ino; // file number of entry
__uint16_t d_reclen; // length of this record
__uint8_t d_type; // file type, see below
__uint8_t d_namlen; // length of string in d_name
char d_name[255 + 1]; // name must be no longer than this
} */
/* #define DT_UNKNOWN 0
#define DT_FIFO 1
#define DT_CHR 2
#define DT_DIR 4
#define DT_BLK 6
#define DT_REG 8
#define DT_LNK 10
#define DT_SOCK 12
#define DT_WHT 14
*/
// struct stat {
// dev_t st_dev; /* device inode resides on */
// ino_t st_ino; /* inode's number */
// mode_t st_mode; /* inode protection mode */
// nlink_t st_nlink; /* number of hard links to the file */
// uid_t st_uid; /* user-id of owner */
// gid_t st_gid; /* group-id of owner */
// dev_t st_rdev; /* device type, for special file inode */
// struct timespec st_atimespec; /* time of last access */
// struct timespec st_mtimespec; /* time of last data modification */
// struct timespec st_ctimespec; /* time of last file status change */
// off_t st_size; /* file size, in bytes */
// quad_t st_blocks; /* blocks allocated for file */
// u_long st_blksize;/* optimal file sys I/O ops blocksize */
// u_long st_flags; /* user defined flags for file */
// u_long st_gen; /* file generation number */
// };
/*---------------------- `ll` command ------------------*/
/* ls -l i.e. long listing of files in a directory */
int myll(int argc, char** argv)
{
struct stat buf;
struct dirent* b1;
DIR* dp;
if (argc != 2)
{
printf("Incorrect usage: <command> <pathname>\n");
return -1;
}
dp = opendir(argv[1]);
//if directory does not exist
if(dp == NULL)
{
printf("Error\n");
return -1;
}
printf("Type\tMode\tLink\tUID\tGID\tSize\tName\t\t\tTime\n");
//read all the files present in the directory and print their attributes
while((b1 = readdir(dp)) != NULL)
{
//load the buffer buf with attributes of file b1->d_name loaded in struct dirent
stat(b1->d_name, &buf);
switch (buf.st_mode & S_IFMT)
{
case S_IFBLK: printf("b"); //block device file
break;
case S_IFCHR: printf("c"); //character dev file
break;
case S_IFDIR: printf("d"); //directory file
break;
case S_IFIFO: printf("p"); //FIFO/pipe file
break;
case S_IFLNK: printf("l"); //symbolic link file
break;
case S_IFREG: printf("f"); //regular file
break;
case S_IFSOCK: printf("s"); //socket
break;
default: printf("?"); //unknown
break;
}
printf("\t%lo\t", (unsigned long) buf.st_mode); //print mode in octal
printf("%ld\t", (long) buf.st_nlink); //print hard link count
printf("%ld\t%ld\t",(long) buf.st_uid, (long) buf.st_gid); //print UID & GID of file
printf("%lld\t", (long long) buf.st_size); //print size of the file in bytes
//printf("%ld\t", (long) buf.st_ino); //print inode number of the file
printf("%-20s\t", b1->d_name); //print name of the file
printf("%s", (char *) (ctime(&buf.st_atime))); //print last access time of the file in string
//format
}
closedir(dp);
return 0;
}
/*---------------------- end of `ll` command ------------------*/
/*---------------------- `ln` command ------------------*/
int myln(int argc, char* argv[])
{
char* sym="-s";
// creating a hard link
if(argc==3)
{
//linking file argv[1] to argv[2]
if((link(argv[1],argv[2]))==0)
{
printf("Link for %s successfully created : %s\n",argv[1],argv[2]);
return 0;
}
//error in creating hard link
else
{
perror("Link error");
return 100;
}
}
//creating a symbolic link
else if(argc==4)
{
//if option -s is used in command line
if((strcmp(sym,argv[1]))==0)
{
//creating a symbolic link of file argv[2] as argv[3]
if((symlink(argv[2],argv[3]))==0)
{
printf("Symbolic link for file %s successfully created : %s\n",argv[2],argv[3]);
return 0;
}
else
{
perror("Symbolic link error");
return errno;
}
}
//error if option -s is not used
else
{
printf("Invalid option used\n");
return 100;
}
}
//user input error
else
{
printf("Incorrect number of arguments : <command> <filename> <linkname> OR <command> -s <filename> <linkname>\n");
return 101;
}
return 0;
}
/*---------------------- end of `ln` command ------------------*/
/*---------------------- `ld` command ------------------*/
/* ls command for checking if multiple files/directories exists or not */
int myld(int argc, char** argv)
{
int i = 1;
while(argv[i]!=NULL)
{
if(access(argv[i], F_OK) == 0)
{
printf("%s\n", argv[i]);
i++;
}
else
{
printf("%s: ls: No such file or directory\n",argv[i]);
i++;
}
}
return 1;
}
/*---------------------- end of `ld` command ------------------*/
/*---------------------- `mkdir` command ------------------*/
int mymkdir(int argc, char** argv)
{
//Correct number of arguments
if(argc==2)
{
//create directory
if(mkdir(argv[1],0777)==0)
{
printf("Directory created : %s\n",argv[1]);
return 0;
}
//directory not created
else
{
perror("Directory error");
return 1;
}
}
//Invalid number of arguments
else
{
printf("Incorrect number of arguments : <command> <dirname>\n");
return 2;
}
}
/*---------------------- end of `mkdir` command ------------------*/
/*---------------------- `mv` command ------------------*/
int mymv(int argc, char** argv)
{
char* pathname;
//3 arguments in command line
if(argc==3)
{
//check if file to be moved exists
if((access(argv[1],F_OK|W_OK))==0)
{
//if link is succesfully created
if(link(argv[1],argv[2])==0)
{
//if file argv[1] is deleted from its original location
if((unlink(argv[1]))==0)
{
printf("%s succesfully moved to %s\n",argv[1],argv[2]);
return 0;
}
else
{
//file argv[1] was not unlinked from original location
perror("Link deletion error");
return 99;
}
}
//link creation failed
else
{
perror("Link creation error");
return 100;
}
}
//file argv[1] does not exist
else
{
perror("File error");
return 101;
}
}
//invalid number of arguments
else
{
printf("Invalid number of arguments : <command> <filename> <pathname/>\n");
return 102;
}
return 0;
}
/*---------------------- end of `mv` command ------------------*/
/*---------------------- `pwd` command ------------------*/
int mypwd(int argc, char** argv)
{
char value[256];
//valid number of arguments
if(argc == 1)
{
//check for PWD in environment list
if(getcwd(value, sizeof(value))!=NULL) //check if value exists in the environment list
{
printf("Current working directory : %s\n",value);
return 0;
}
//failed to retrieve PWD from environment list
else
{
printf("Current working directory not found\n");
return -1;
}
}
else
{
printf("Incorrect number of arguments : <command>\n");
return -1;
}
}
/*---------------------- end of `pwd` command ------------------*/
/*---------------------- `rm` command ------------------*/
int myrm(int argc, char** argv)
{
if(argc==2)
{
//if file at given pathname exists
if(access(argv[1],F_OK|W_OK)==0)
{
//unlink API successful
if(unlink(argv[1])==0)
{
printf("%s deleted\n",argv[1]);
}
//unlink API unsuccessful i.e. file not deleted
else
{
perror("File deletion error");
return 99;
}
}
//given file at pathname does not exist
else
{
perror("File access error");
return 100;
}
}
//invalid number of arguments
else
{
printf("Incorrect number of arguments : <command> <file-pathname\n");
return 101;
}
}
/*---------------------- end of `rm` command ------------------*/
/*---------------------- `rmdir` command ------------------*/
int myrmdir(int argc, char** argv)
{
//Correct number of arguments
if(argc==2)
{
//if deleted
if(rmdir(argv[1]) == 0)
{
printf("Directory removed : %s\n",argv[1]);
return 0;
}
//if not deleted
else
{
perror("Directory error");
return 1;
}
}
//Invalid number of arguments
else
{
printf("Incorrect number of arguments : <command> <dirname>\n");
return 2;
}
}
/*---------------------- end of `rmdir` command ------------------*/
/*---------------------- `tail` command ------------------*/
int mytail(int argc, char** argv)
{
int fd, n, i, count=0;
char line [MAX];
FILE* fp;
char lines[MAX][MAX];
//number of lines specified
if(argc == 3)
{
n = atoi(argv[1]);
fp = fopen(argv[2], "r");
}
//number of lines not specified, taken as last 10 lines by default
else if(argc == 2)
{
n = 10;
fp = fopen(argv[1], "r");
}
//incorrect number of arguments
else
{
printf("Incorrect usage : <command> <filename> | <command> <num_lines> <filename>\n");
return -1;
}
if(fp == NULL)
{
perror("File error");
return -2;
}
//read the entire file as lines and store 'line' in 2d array 'lines'
while(fgets(line, sizeof line ,fp)!= NULL)
{
strcpy(lines[count], line);
count++;
}
fclose(fp);
//count is the total number of lines in file
//n is number of lines to be printed
for(i=(count - n); i<=count; i++)
{
printf("%s", lines[i]);
}
return 0;
}
/*---------------------- end of `tail` command ------------------*/
/*---------------------- `time` command ------------------*/
int mytime(int argc, char** argv)
{
struct tms buf;
//Invalid number of arguments
if(argc != 1)
{
printf("Incorrect number of arguments : <command>\n");
return -1;
}
//call the times() function and populate the buffer 'buf' with values
if(times(&buf) != -1)
{
printf("User time : %ld\n",buf.tms_utime);
printf("System time : %ld\n",buf.tms_stime);
printf("User time of children : %ld\n",buf.tms_cutime);
printf("System time of children : %ld\n",buf.tms_cstime);
return 0;
}
}
/*---------------------- end of `time` command ------------------*/
/*---------------------- `touch` command ------------------*/
int mytouch(int argc, char** argv)
{
//number of arguments = 2
if(argc==2)
{
//if file exists
if((access(argv[1],F_OK|W_OK))==0)
{
//if access time changed
if(utime(argv[1],NULL)==0) //NULL indicates set to the current time; only SU or owner of file can
//define time to be set if other than current time
{
return 0;
}
//access time not changed
else
perror("Error");
}
//file does not exist
else
{
//file is created
if(open(argv[1],O_CREAT|O_RDWR,0777)!=-1)
{
printf("File created : %s\n",argv[1]);
}
//file not created error
else
perror("File error");
}
}
//incorrect number of arguments
else
{
printf("Incorrect number of arguments : <command> <pathname>\n");
return 100;
}
}
/*---------------------- end of `touch` command ------------------*/
/*---------------------- `uname` command ------------------*/
int myuname(int argc, char** argv)
{
struct utsname buf;
if(argc > 2)
return -1;
if(uname(&buf) != -1)
{
//if user inputs only uname or uname -s
if(argc == 1 || ((strcmp(argv[1], "-s") == 0) && argc == 2))
{
//print os name
printf("OS Name : %s\n", buf.sysname);
return 0;
}
//if user inputs uname -r
if(strcmp(argv[1], "-r") == 0)
{
printf("Release: %s\n", buf.release);
return 0;
}
//user inputs uname -v
if(strcmp(argv[1], "-v") == 0)
{
printf("Version : %s\n", buf.version);
return 0;
}
}
return 0;
}
/*---------------------- end of `uname` command ------------------*/
/*---------------------- `clear` command ------------------*/
void myclear()
{
/*
we print the escape sequence that we get via running this command
$ tput clear | od -c
0000000 033 [ H 033 [ 2 J
\033 is octal for Esc and thus we print these sequences every time we call clear.. if clear command does not run successfully the output of the above command must be printed instead of the existing printf() statement
*/
printf("\033[H\033[2J");
}
/*---------------------- end of `clear` command ------------------*/
int main(int argc, char** argv)
{
int count=0, i=0, cmp, j, valid=0;
char key[MAX];
//run the shell till user inputs 'quit' or Ctrl-C
while(strcmp(cmdline, "quit") != 0)
{
count = 0;
//our shell's prompt
printf("afreen@myShell $ ");
//get command line input
gets(cmdline);
//tokenize the CL input delimited by " " using strtok() into args
args[count++] = strtok(cmdline, " ");
//tokenize the entire string till the next token encountered
//does not have a NULL pointer
while((args[count++] = strtok(NULL, " ")));
count--; //no of arguments (argc)
//if user wants to clear screen
if(strcmp(args[0], "clear") == 0)
{
myclear();
}
//checking for the input command
strcpy(key, args[0]);
for(i=0; i<18; i++) //look through our check array for command
{
if(strcmp(check[i], key) == 0)
{
valid = -1;
switch(i)
{
case 0: mycat(count, args);
break;
case 1: mycd(count, args);
break;
case 2: mycp(count, args);
break;
case 3: mydate(count, args);
break;
case 4: myhead(count, args);
break;
case 5: myls(count, args);
break;
case 6: myll(count, args);
break;
case 7: myln(count, args);
break;
case 8: myld(count, args);
break;
case 9: mymkdir(count, args);
break;
case 10: mymv(count, args);
break;
case 11: mypwd(count, args);
break;
case 12: myrm(count, args);
break;
case 13: myrmdir(count, args);
break;
case 14: mytail(count, args);
break;
case 15: mytime(count, args);
break;
case 16: mytouch(count, args);
break;
case 17: myuname(count, args);
break;
default: printf("%s: Command not found\n", key);
break;
}
break;
}
}
}
return 0;
}