final1
This commit is contained in:
parent
0e8d433065
commit
0f2b0f2919
@ -19,7 +19,18 @@ spath:
|
|||||||
help - shows help page
|
help - shows help page
|
||||||
0 - turns off displaying current directory
|
0 - turns off displaying current directory
|
||||||
1 - turns on displaying current directory
|
1 - turns on displaying current directory
|
||||||
PATH commands
|
showtree:
|
||||||
|
help - shows help page
|
||||||
|
no argument - shows tree of current directory
|
||||||
|
one argument - shows tree of directory in argument
|
||||||
|
showps:
|
||||||
|
help - shows help page
|
||||||
|
prints all process names ond pids
|
||||||
|
mycp:
|
||||||
|
help - shows help page
|
||||||
|
with 2 arguments - copyies file from first argument to
|
||||||
|
file in second argument
|
||||||
|
PATH commands:
|
||||||
if you want colors use
|
if you want colors use
|
||||||
for example ls --color
|
for example ls --color
|
||||||
|
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
To jest plik1.txt
|
|
||||||
jajajajaj
|
|
@ -1 +0,0 @@
|
|||||||
testtt
|
|
Binary file not shown.
@ -87,7 +87,7 @@ void help (char **argv){
|
|||||||
void exe (char **argv){
|
void exe (char **argv){
|
||||||
if (fork() == 0){
|
if (fork() == 0){
|
||||||
execvp(argv[0], argv);
|
execvp(argv[0], argv);
|
||||||
perror("execvp");
|
perror("Comand execution error");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -102,7 +102,7 @@ void ptab (int ile){
|
|||||||
|
|
||||||
void tree (char **argv, char * directory){
|
void tree (char **argv, char * directory){
|
||||||
if (argv[1] != NULL && argv[2] != NULL){
|
if (argv[1] != NULL && argv[2] != NULL){
|
||||||
printf("Too many arguments\nshowtree takes no arguments \nor exacly 1 argument for desired directory\n");
|
printf("Too many arguments\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -113,12 +113,16 @@ void tree (char **argv, char * directory){
|
|||||||
int tab = 0;
|
int tab = 0;
|
||||||
|
|
||||||
if (argv[1] != NULL && argv[2] == NULL){ /*jeden argument*/
|
if (argv[1] != NULL && argv[2] == NULL){ /*jeden argument*/
|
||||||
|
if (!strcmp(argv[1], "help")){
|
||||||
|
printf("Showtree prints catalog and file structure\ntakes no arguments \nor exacly 1 argument for desired directory\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
cd(argv);
|
cd(argv);
|
||||||
getcwd(ndr, sizeof(ndr));
|
getcwd(ndr, sizeof(ndr));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strcpy(ndr, directory);
|
strcpy(ndr, directory);
|
||||||
printf("Content of: %s\n", ndr);
|
printf("Content of: %s\n\n", ndr);
|
||||||
|
|
||||||
if ((d = opendir(ndr)) != NULL){ /*wchodzimy do katalogu*/
|
if ((d = opendir(ndr)) != NULL){ /*wchodzimy do katalogu*/
|
||||||
while ((ent = readdir(d)) != NULL){ /*czytamy zawartosc*/
|
while ((ent = readdir(d)) != NULL){ /*czytamy zawartosc*/
|
||||||
@ -156,11 +160,16 @@ void tree (char **argv, char * directory){
|
|||||||
|
|
||||||
void mycp (char **argv){
|
void mycp (char **argv){
|
||||||
if (argv[1] == NULL || argv[2] == NULL){
|
if (argv[1] == NULL || argv[2] == NULL){
|
||||||
printf("Add arguments\n");
|
if(argv[1] != NULL && argv[2] == NULL)
|
||||||
|
if (!strcmp(argv[1], "help")){
|
||||||
|
printf("Needs exacly 2 arguments\ncopyies file from first argument to file in second argument\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("Add arguments\nfor more info type 'mycp help'\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (argv[3] != NULL){
|
else if (argv[3] != NULL){
|
||||||
printf("Too many arguments\n");
|
printf("Too many arguments\nfor more info type 'mycp help'\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -190,6 +199,14 @@ void mycp (char **argv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void myps (char **argv){
|
void myps (char **argv){
|
||||||
|
if (argv[1] != NULL){
|
||||||
|
if(!strcmp(argv[1], "help")){
|
||||||
|
printf("Showps prints all prosess and pids\ntakes no arguments\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("Type 'showps help'\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (fork() == 0){
|
if (fork() == 0){
|
||||||
if (chdir("/proc") != 0){
|
if (chdir("/proc") != 0){
|
||||||
perror("cant open /proc");
|
perror("cant open /proc");
|
||||||
|
Loading…
Reference in New Issue
Block a user