To make your own Doss Shell  / Prompt Just Write that piece of code in C++ editor such as Turboo C or any other editor and Run it..!
#include<iostream.h>
#include<conio.h>
#include<dir.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<fstream.h>

main(int argc , char *argv[])
{
    clrscr();
    char string[10];

    do
    {
      newstep:
              cout<<"MY Prompt>";
              gets(command);
              char *p[3];
              p[0] = strtok(command, " ");
              p[1] = strtok(NULL, " ");
              p[2] = strtok(NULL, " ");

              if (!strcmp(p[0],"help"))
              {

                  cout<<"Command Of MY Prompt"<<endl;
                  cout<<"cls\t\t to Clear the Screen"<<endl;
                  cout<<"dir\t\t to view directory"<<endl;
                  cout<<"delete\t\t to File"<<endl;
                  cout<<"exit\t\t to exit"<<endl;
                  cout<<"fcopy\t\t to Copy Contents Of File"<<endl;
                  cout<<"mkfd\t\t to Make Directory/Folder"<<endl;
                  cout<<"viewfile\t\t to view Contents of File<<endl"<<endl;
                  cout<<"Press Any Key To Continue:"<<endl;
                  getch();

              }
              else if (!strcmp(p[0],"dir"))
              {
                  system("dir");
              }
              else if (!strcmp(p[0],""))
              {
                  goto newstep;
              }
              else if (!strcmp(p[0],"mkfd"))
              {
                  int a;
                  char *name;
                  cin>>name;
                  a=mkdir(name);
                  if (a==0)
                  {
                        cout<<"Directory is created "<<endl;
                  }
                  else
                        cout<<"Error in creating directory"<<endl;
              }


              else if (!strcmp(p[0],"fcopy"))
              {

                  char data;
                  char *fname;
                  char *fname2;

                  cin>>fname>>fname2;

                  ifstream infile;
                  ofstream outfile;

                  infile.open(fname);
                  outfile.open(fname2);
                  if (infile.fail())
                  {
                     cout<<"file not found "<<endl;
                  }
                  else if (outfile.fail())
                  {
                     cout<<"target file cant be created file "<<endl;
                  }
                   while (!infile.eof())
                  {
                        infile.get(data);
                        outfile<< data;
                  }
                  infile.close();
                  outfile.close();
                  cout<<"File copied from "<<fname<<" to "<<fname2<<endl;


              }
              else if (!strcmp(p[0],"viewfile"))
              {

                  ifstream f;
                  char c;
                  char *b;
                  cin>>b;
                  f.open(b);

                  if(f.fail() || f.eof())
                  {
                        cout<<"File not found";
                  }
                  while(!f.fail() && !f.eof())
                  {
                        f.get(c);
                        cout<<c;

                  }
                  cout<<endl;
                  f.close();
              }
              else if (!strcmp(p[0],"delete"))
              {
                  char *fname;
                  cin>>fname;
                  int a;
                  a= remove(fname);
                  if( a==1)
                  {
                        cout<<"error while deleting... file not deleted "<<endl;

                  }
                  else
                  {
                        cout<<"1 file deleted "<<endl;

                  }
              }



              else if (!strcmp(p[0],"cls"))
              {
                  clrscr();
              }
              else if (!strcmp(p[0],"exit"))
              {
                  break;
              }

              else
                 cout<<"Invalid Command"<<endl;
              goto newstep;

    }
    while(p[0]);

    cout<<endl<<endl<<"\t\t\t"<<"Thanks For Using our Shell System"<<endl<<endl<<endl;
    getch();
    exit(1);

}
Posted by Unknown On Sunday, April 20, 2014 No comments

0 comments:

Post a Comment

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

Like us

    as

    Contact Form

    Name

    Email *

    Message *