#include #include #include #include #include #include #include void showlogo() { printf("\n\n"); printf("================================================================================\n"); printf(" m(etalsvm)shell\n\n"); printf(" Copyright 2011 Stefan Lankes, Chair for Operating Systems,\n"); printf(" RWTH Aachen University\n\n"); printf("================================================================================\n"); } void help() { printf("possible commands: \n"); printf("exit > exit shell \n"); } int main(int argc, char** argv) { char* command = malloc(1024*sizeof(char)); int size, status = 0; pid_t pid; system("clear"); showlogo(); while(1) { printf("$ "); size = scanf("%s", command); if(!strcmp(command, "exit")) { return 0; } if(!strcmp(command, "help")) { help(); } else { pid = fork(); if (pid == 0) { //child char* newargv[] = {command, NULL}; char* newenv[] = {"USER=root", "PATH=/bin:/sbin:/usr/bin", "PWD=/", "TEMP=/tmp", NULL}; execve(command, newargv, newenv); return errno; } else { wait(&status); } } } return errno; }