0

In Operating System concept i want to write a C program to make Unix command works as DOS commands. It Means when ever i press Unix Command like ls -which is used for Display list of Files- it works like Dir command in DOS.Could you please help me out with this?

3
  • Most shells have the ls command built-in, and it often contain many options to control its output. So what you should do is create a shell alias to add the options you want for the format you want. Commented Mar 27, 2015 at 9:48
  • ls -l | awk '{printf "%s %s %s %20d %s\n", $6, $7, $8, $5, $9}' Commented Mar 27, 2015 at 10:04
  • 1
    You can study source code of the win-bash - "A stand-alone bash for Windows" or Cygwin - "Get that Linux feeling - on Windows" projects. They do what you want to build, but in a more complete and more complicated way than "practice and write a c program to do so". Studying similar/competitor's source code is good way to find out how to implement things Commented Mar 27, 2015 at 12:57

1 Answer 1

2

Starting with the ls command as example, take input from user for the command. If the command is ls call a windows function that will display the content of the current working directory(). For ls,

  1. you need to get first the current working directory. GetCurrentDir() for windows will be your first step. This will help How do I get the directory that a program is running from?
  2. Then you can list the files in directory like this https://msdn.microsoft.com/en-us/library/windows/desktop/aa365200(v=vs.85).aspx. But you do need the output of first step.

Other commands can also be implemented like this

Sign up to request clarification or add additional context in comments.

4 Comments

Are you sure the OP want to create the program under windows?
No alk, I just want to practice and write a c program to do so, if i can!!!.and i would appreciate to help me out with this.thanks
Look at the title, Run unix commands to DOS. Then it must be in windows
sorry, yes it is in windows :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.