Overview of command execution by CLI (Command Line Interpreter).
If we talk about the main or primary function of a CLI is to take and execute the user-specified commands.
Most of the CLI (Command line Interpreter) command which we use in our day to day life is related to file and folders like Create, Delete, List, Copy, Execute and so on. So for this primary, there were two approaches by which these commands get executed by the Operating system are as follows:
1st Approach: This approach can be seen as a naive approach or a Brute-force solution to the problem. In this, the Interpreter is solely for all the execution starting from taking the command to the execution of that command over that specific file or folder. If I talk more specifically the let suppose an example of :
Let suppose the user typed a command for removing or deleting a file on the interpreter: “rm samplefile.txt”. Then after receiving that command the Command Interpreter jumps to a section of its code that set up the parameter which is basically “filename” in this context and after this an appropriate system call is made. Now it seems to be fine but here is a limitation due to which this approach is not so efficient for the system.
Limitation of the above Approach: The biggest or can say the major one is the number of Command from the user is restricted to the size of the command interpreter.
2nd Approach: Talking about this approach, so this approach is the optimal version of the above approach. In this approach, the work is distributed so the limitation that we are facing in the above approach can be optimised or resolved. This approach also I wanna take the same example of deleting a file.
Let suppose the user typed the command “rm samplefile1.txt” then after this the Command interpreter just have to search with the file name of — “ rm ” and load into memory and then execute it with a parameter which is the file name in the command — “ samplefile1.txt”. After this, the function associated with “rm” does the delete operations. So by this procedure, the Command interpreter is not going to stuck for a while.
Advantages:
— By this approach, the limitation of the first approach is resolved and now the Command given by the user doesn’t limit to the size of the Command Interpreter.
— Can create a new command easily like “rm” with this approach because in this we just have to make a file with a specific and unique name and also have some function associated with it.
Most of the Operating Sys. like (UNIX, LINUX, e.t.c) uses this approach, but as we know every coin has two phases so this Approach have also some flaws but the constantly evolving technology and science will going to search for something new and more efficient or maybe SEARCHED!