karanmc / lab-2

Operating Systems Lab 2
0 stars 1 forks source link

New error list for myshell.c @ 10.35pm #7

Open karanmc opened 9 years ago

karanmc commented 9 years ago

myshell.c: In function ‘main’: myshell.c:33:26: error: ‘shellcwd’ undeclared (first use in this function) getcwd(shell, sizeof(shellcwd)); ^ myshell.c:33:26: note: each undeclared identifier is reported only once for each function it appears in myshell.c:34:18: warning: unknown escape sequence: '\m' [enabled by default] strcat(shell,"\myshell");//store shells working directory ^ myshell.c:76:15: error: incompatible types when assigning to type ‘char[256]’ from type ‘char *’ command = "cd"; //switch to cd command ^ myshell.c:95:1: error: expected expression before ‘<<’ token <<<<<<< HEAD ^ myshell.c:97:1: error: expected expression before ‘==’ token

^ myshell.c:99:9: error: invalid suffix "d1a1cd10436e5c8215baad5f44c5edf1034907" on integer constant

04d1a1cd10436e5c8215baad5f44c5edf1034907 ^ myshell.c:109:10: warning: implicit declaration of function ‘strcad’ [-Wimplicit-function-declaration] strcad(arg,"\n"); ^ myshell.c:114:10: error: ‘line’ undeclared (first use in this function) line = fgetc(readme); ^

alexmcgilvery commented 9 years ago

make sure there is none of those HEAD lines in code, <<<<<<< HEADm, ======= etc. Auto generated when merge for some reason.

karanmc commented 9 years ago

ok, will check and compile again

alexmcgilvery commented 9 years ago

like that d1a1cd10436e5c8215baad5f44c5edf1034907 random line

karanmc commented 9 years ago

Yep, commented everything unnecessary out. A lot less error:

myshell.c: In function ‘main’: myshell.c:70:15: error: incompatible types when assigning to type ‘char[256]’ from type ‘char *’ command = "cd"; //switch to cd command ^ myshell.c:94:9: error: expected ‘;’ before ‘}’ token } ^


The error on line 94 is alright. The only thing is the command = "cd". not sure why that's an issue

alexmcgilvery commented 9 years ago

I got rid of command = "cd" so idk why that would error, maybe update code to my commit?

alexmcgilvery commented 9 years ago

also line 35 get rid of the r that i accidentally left in-front of the string "\myshell"

karanmc commented 9 years ago

I can't find the 'r', but when I comment out the command="cd", the code compiles. I'll push the code to the repo

alexmcgilvery commented 9 years ago

update your code to newest commit I changed the command = "cd" and other stuff in newest merge

karanmc commented 9 years ago

ohh ok will do

karanmc commented 9 years ago

I updated the code to the latest merge. the last pull request was 30 mins ago. Still get these errors:

myshell.c: In function ‘main’: myshell.c:35:18: error: ‘r’ undeclared (first use in this function) strcat(shell,r"\myshell");//store shells working directory ^ myshell.c:35:18: note: each undeclared identifier is reported only once for each function it appears in myshell.c:35:19: error: expected ‘)’ before string constant strcat(shell,r"\myshell");//store shells working directory ^ myshell.c:100:9: error: expected ‘;’ before ‘}’ token } ^ myshell.c:109:10: warning: implicit declaration of function ‘strcad’ [-Wimplicit-function-declaration] strcad(arg,"\n"); ^ myshell.c:114:10: warning: passing argument 1 of ‘fgets’ from incompatible pointer type [enabled by default] line = fgets(readme); ^ In file included from myshell.c:8:0: /usr/include/stdio.h:622:14: note: expected ‘char * restrict’ but argument is of type ‘struct FILE ’ extern char fgets (char restrict s, int __n, FILE restrict stream) ^ myshell.c:114:10: error: too few arguments to function ‘fgets’ line = fgets(readme); ^ In file included from myshell.c:8:0: /usr/include/stdio.h:622:14: note: declared here extern char fgets (char restrict s, int n, FILE *restrict stream) ^ myshell.c:115:22: warning: comparison between pointer and integer [enabled by default] while (line != EOF){ ^ myshell.c:117:14: warning: passing argument 1 of ‘fgets’ from incompatible pointer type [enabled by default] line = fgets(readme); ^ In file included from myshell.c:8:0: /usr/include/stdio.h:622:14: note: expected ‘char * restrict’ but argument is of type ‘struct FILE ’ extern char fgets (char *restrict s, int n, FILE restrict stream) ^ myshell.c:117:14: error: too few arguments to function ‘fgets’ line = fgets(readme); ^ In file included from myshell.c:8:0: /usr/include/stdio.h:622:14: note: declared here extern char fgets (char restrict s, int __n, FILE restrict stream) ^

karanmc commented 9 years ago

my bad wasn't supposed to be bold lol

alexmcgilvery commented 9 years ago

changed some stuff, add new commit and try again

karanmc commented 9 years ago

ok

karanmc commented 9 years ago

the files on github aren't updating. did you submit a merge request?

karanmc commented 9 years ago

oh wait I got it

karanmc commented 9 years ago

but it says "This branch has conflicts that must be resolved" and I can't merge it

alexmcgilvery commented 9 years ago

it says all you need is write access

alexmcgilvery commented 9 years ago

try some way of force merge

karanmc commented 9 years ago

ok

alexmcgilvery commented 9 years ago

here is code:

/*

// Put macros or constants here using #define

define BUFFER_LEN 256

// Put global environment variables here

// Define functions declared in myshell.h here

int main(int argc, char *argv[]) { // Input buffer and and commands char buffer[BUFFER_LEN] = { 0 }; char command[BUFFER_LEN] = { 0 }; char arg[BUFFER_LEN] = { 0 }; char cwd[BUFFER_LEN] = { 0 }; char line[BUFFER_LEN] = { 0 };

char shell[BUFFER_LEN] = { 0 };
getcwd(shell, sizeof(shell));
strcat(shell,"\\myshell");//store shells working directory

int paused = 0;

FILE *readme;

// Parse the commands provided using argc and argv
// Perform an infinite loop getting command input from users
while (fgets(buffer, BUFFER_LEN, stdin) != NULL)
{
    // Perform string tokenization to get the command and argument
    sscanf(buffer,"%s %s",command,arg); // Parse the commands provided using argc and argv

    // Check the command and execute the operations for each command

    //pause has priority, we want to check if paused or not before checking if its actually a command
    if (strcmp(command,"pause")== 0 && paused != 0 && strcmp(arg, "") == 0){
        paused = 1;
    }
    else if (paused == 0){
        if (strcmp(buffer, "\n") == 0){
            paused = 0;
        }
    }
      // cd command -- change the current directory
    else if (strcmp(command, "cd") == 0)
    {
        if (strcmp(arg,"")!= 0){
            strcat(command," ");
            strcat(command,arg);
            system(command);
        }
        else{
            system("pwd");
        }

    }
    // directory listing
    else if (strcmp(command, "dir") == 0 && strcmp(arg, "") == 0)
    {
        getcwd(cwd, sizeof(cwd)); //store cwd
        strcpy(command,"cd"); //switch to cd command
        strcat(command," ");
        strcat(command,arg);
        system(command);
        system("ls"); // display all files (linux) within cwd
        strcat(command," ");
        strcat(command,cwd);
        system(command);//cd back to stored cwd

    }
    //enviorment variables
    else if (strcmp(command, "environ") == 0 && strcmp(arg, "") == 0)
    {
        system("printenv"); // again linux terminal usage
    }

    // clear command
    else if (strcmp(command,"clr")== 0){
        //system("cls"); // windows terminal usage
        system("reset"); // linux terminal usage
    }
    // quit command -- exit the shell
    else if (strcmp(command, "quit") == 0 && strcmp(arg, "") == 0)
    {
        return EXIT_SUCCESS;
    }
    // echo command -- repeat back argument then move to next line with \n
    else if (strcmp(command, "echo") == 0 )
    {
        strcat(arg,"\n");
        fputs(arg,stderr);
    }
    else if (strcmp(command, "help") == 0 && strcmp(arg, "") == 0){
        readme = fopen("README.md", "rt");
        fgets(line,BUFFER_LEN,readme);
        while (line != EOF){
            fputs(line,stderr);
            line = fgets(readme);
        }
        fclose(readme);
    }
    // Unsupported command
    else
    {
        fputs("Unsupported command, use help to display the manual\n", stderr);
    }
}
return EXIT_SUCCESS;

}

alexmcgilvery commented 9 years ago

just copy this and paste onto yours

karanmc commented 9 years ago

compiled it, but still get a bunch of errors:

myshell1.c: In function ‘main’: myshell1.c:111:21: error: ‘BUFFER_LENreadme’ undeclared (first use in this function) fgets(line,BUFFER_LENreadme); ^ myshell1.c:111:21: note: each undeclared identifier is reported only once for each function it appears in myshell1.c:111:10: error: too few arguments to function ‘fgets’ fgets(line,BUFFER_LENreadme); ^ In file included from myshell1.c:8:0: /usr/include/stdio.h:622:14: note: declared here extern char fgets (char restrict s, int n, FILE *restrict stream) ^ myshell1.c:112:22: warning: comparison between pointer and integer [enabled by default] while (line != EOF){ ^ myshell1.c:114:14: warning: passing argument 1 of ‘fgets’ from incompatible pointer type [enabled by default] line = fgets(readme); ^ In file included from myshell1.c:8:0: /usr/include/stdio.h:622:14: note: expected ‘char * restrict’ but argument is of type ‘struct FILE ’ extern char fgets (char *restrict s, int n, FILE restrict stream) ^ myshell1.c:114:14: error: too few arguments to function ‘fgets’ line = fgets(readme); ^ In file included from myshell1.c:8:0: /usr/include/stdio.h:622:14: note: declared here extern char fgets (char restrict s, int __n, FILE restrict stream) ^

karanmc commented 9 years ago

I copied and compiled your latest merge

alexmcgilvery commented 9 years ago

k lemme fix

karanmc commented 9 years ago

ok. is it due at 11.59?

alexmcgilvery commented 9 years ago

here:

/*

// Put macros or constants here using #define

define BUFFER_LEN 256

// Put global environment variables here

// Define functions declared in myshell.h here

int main(int argc, char *argv[]) { // Input buffer and and commands char buffer[BUFFER_LEN] = { 0 }; char command[BUFFER_LEN] = { 0 }; char arg[BUFFER_LEN] = { 0 }; char cwd[BUFFER_LEN] = { 0 }; char line[BUFFER_LEN] = { 0 };

char shell[BUFFER_LEN] = { 0 };
getcwd(shell, sizeof(shell));
strcat(shell,"\\myshell");//store shells working directory

int paused = 0;

FILE *readme;

// Parse the commands provided using argc and argv
// Perform an infinite loop getting command input from users
while (fgets(buffer, BUFFER_LEN, stdin) != NULL)
{
    // Perform string tokenization to get the command and argument
    sscanf(buffer,"%s %s",command,arg); // Parse the commands provided using argc and argv

    // Check the command and execute the operations for each command

    //pause has priority, we want to check if paused or not before checking if its actually a command
    if (strcmp(command,"pause")== 0 && paused != 0 && strcmp(arg, "") == 0){
        paused = 1;
    }
    else if (paused == 0){
        if (strcmp(buffer, "\n") == 0){
            paused = 0;
        }
    }
      // cd command -- change the current directory
    else if (strcmp(command, "cd") == 0)
    {
        if (strcmp(arg,"")!= 0){
            strcat(command," ");
            strcat(command,arg);
            system(command);
        }
        else{
            system("pwd");
        }

    }
    // directory listing
    else if (strcmp(command, "dir") == 0 && strcmp(arg, "") == 0)
    {
        getcwd(cwd, sizeof(cwd)); //store cwd
        strcpy(command,"cd"); //switch to cd command
        strcat(command," ");
        strcat(command,arg);
        system(command);
        system("ls"); // display all files (linux) within cwd
        strcat(command," ");
        strcat(command,cwd);
        system(command);//cd back to stored cwd

    }
    //enviorment variables
    else if (strcmp(command, "environ") == 0 && strcmp(arg, "") == 0)
    {
        system("printenv"); // again linux terminal usage
    }

    // clear command
    else if (strcmp(command,"clr")== 0){
        //system("cls"); // windows terminal usage
        system("reset"); // linux terminal usage
    }
    // quit command -- exit the shell
    else if (strcmp(command, "quit") == 0 && strcmp(arg, "") == 0)
    {
        return EXIT_SUCCESS;
    }
    // echo command -- repeat back argument then move to next line with \n
    else if (strcmp(command, "echo") == 0 )
    {
        strcat(arg,"\n");
        fputs(arg,stderr);
    }
    else if (strcmp(command, "help") == 0 && strcmp(arg, "") == 0){
        readme = fopen("README.md", "rt");
        fgets(line,BUFFER_LEN,readme);
        while (line != EOF){
            fputs(line,stderr);
            line = fgets(line,BUFFER_LEN,readme);
        }
        fclose(readme);
    }
    // Unsupported command
    else
    {
        fputs("Unsupported command, use help to display the manual\n", stderr);
    }
}
return EXIT_SUCCESS;

}

alexmcgilvery commented 9 years ago

yes due then, compile this quick and just had it in

karanmc commented 9 years ago

ok. I cant hand it in though. the group doesnt dhow up on my blackboard

alexmcgilvery commented 9 years ago

attach file to this comment

alexmcgilvery commented 9 years ago

ill hand it in

karanmc commented 9 years ago

ok

alexmcgilvery commented 9 years ago

just make sure no syntax errors

karanmc commented 9 years ago

cant upload files here, not allowing

alexmcgilvery commented 9 years ago

email to james.morrison1@uoit.net

karanmc commented 9 years ago

ok

karanmc commented 9 years ago

sent

alexmcgilvery commented 9 years ago

handed it in

karanmc commented 9 years ago

perfect, thanks