+ 2

how to create CLI programs?

how do i create a built-in CLI programs like ls, cd and wget to access automatically from the terminal?

11th Nov 2020, 11:48 PM
Shen Bapiro
Shen Bapiro - avatar
5 Respostas
+ 8
shell programs are written in shell script for unix based systems (linux, mac osx) and batch scripts for windows. it’s a process that is a little detailed to fully explain on a post, but to summarize, you would write the script and save it somewhere on your system to a .sh or .bat file respectively. then, you would add the file path of the script or the directory its in to your system’s PATH variable. Here’s an interesting article for doing so on unix based systems: https://link.medium.com/gVZHsED6kbb Programs do not have to be written in shell script or batch. You can write a script in almost any programming language, including python and java, and it can be turned into a commands. They just have to be added to the systems PATH variable.
12th Nov 2020, 12:16 AM
Brian R
Brian R - avatar
+ 9
This is different for various Operating Systems. For Windows the easiest way is to create the executable and then copy or move it into the same directory as the other CLI executables (location of which escapes me at the moment, but should easy enough to find) or place it in a directory location you desire and add its file path to the systems or users %path% environment variable. For Unix systems it is similar but you will need to edit the bash_profile to add the path. Google will be your friend here.
12th Nov 2020, 12:15 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
thx for the helpful guides guys, i'll research further from here
12th Nov 2020, 1:53 AM
Shen Bapiro
Shen Bapiro - avatar