Results 1 to 4 of 4

Thread: help with shell

  1. #1
    Join Date
    Nov 2005
    Posts
    2

    Unanswered: help with shell

    can any one help me with this shell problem please

    The
    shell will loop continuously to accept user commands; it will terminate when "exit" is
    entered. The command line prompt must contain the pathname of the current directory.
    Internal commands
    The shell must support the following internal commands:
    First: /ayed/ > cd [[<pathname>] <directory>]
    Change the current default directory to <directory>. If the <directory> is not present,
    report the current directory. If the directory does not exist an appropriate error message
    should be reported.
    e.g.
    /ayed/> cd project or /ayed/> cd /ayed/project
    Second: History
    Display a history of the last 10 commands executed on the shell.
    Third : exit
    Quit the shell.
    Other than that the program shall read, parse and interpret the command and call the
    appropriate command from the existing shell.
    For simplicity sake, assume that only the following commands can be input to the shell:
    1. ls
    2. ls -l
    3. date
    4. pico <filename>
    5. history
    6. man <subject>
    7. diff <filename1> <filename2>
    8. set
    9. who
    10. rlogin <host-name>
    The shell should fork a new process for each executed command.

    Program Skeleton:
    while(! EOF) {
    read input
    handle regular expressions; // parse the next command by the user.
    if(built-in command) {
    execute command; continue; }
    if(child = fork()) { // create a child to run command
    child = wait(&res);
    }
    else { // command is run here
    exec(command, argc, argv0, argv1, )
    }
    }

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


    This looks like a HOMEWORK assignment.
    Have you tried coding something on your own?
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Nov 2005
    Posts
    2
    sudo could be can be a simple option just give the user access to the list of commands through sudoers.

  4. #4
    Join Date
    Nov 2005
    Posts
    2

    Red face i tryed

    well i realy tryed to solve it
    this is what i thought of but i just dont know what to do next
    so any one can help me and tell me what to do next
    i mean i dont know what to fork
    can any one help me please
    #include <iostream>



    void push (char input);
    bool IsFull (void);
    bool IsEmpty (void);
    void pop (void);
    void history (void);









    using namespace ::std;

    char input;
    int max=10;
    int front=-1;
    char *queue;
    int rear=-1;
    void main(){



    cin>> input;

    while(input != 'e')


    {

    if(input=='h'){
    push(input);
    history();
    }

    }
    if(input=='e')

    cout<<"exit"<<endl;





    }



    void push (char input) {

    if (IsFull())
    {
    pop();
    queue[++rear]=input;
    }

    else
    queue[++rear]=input;

    }


    void pop (void){

    if (IsEmpty())
    cout<<"Is Empty"<<endl;

    else

    queue[++front];

    }



    bool IsFull (void){

    if (rear==max-1 && front==-1)
    return true;

    else
    return false;

    }




    bool IsEmpty (void){

    if (rear== front)
    return true;

    else
    return false;

    }



    void history (void){

    while (!IsEmpty())

    {
    cout<<queue[rear]<<endl;
    rear--;
    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •