This tutorial explains how to create an executable command file in MAC OS. MAC commands executable / batch file consisting of commands to run (an alternate to .bat file of windowsOS in MacOC).
If you have worked on windows command prompt, you might used .bat or batch file which will have all the commands that you want to run, and when you double click on the .bat file, commands will be executed one by one.
In MacOS you can create a new file with file extension / format as .command and enter all the commands you want to run as you run manually on MAC terminal.
Follow the below steps :
1. Create a new file, Spotlight | TextEdit or any kind of text editor
2. Enter the commands to run from executable file, for example we will execute below command
4. Double click the file that you just saved to execute
Open the terminal and enter below command for the file to run,
chmod u+x /path/to/.command/file
Now double click on the .command file, you will see the out put on a terminal with out any error. Thank you for reading this article, and if you have any problem, have a another better useful solution about this article, please write message in the comment section.
If you have worked on windows command prompt, you might used .bat or batch file which will have all the commands that you want to run, and when you double click on the .bat file, commands will be executed one by one.
In MacOS you can create a new file with file extension / format as .command and enter all the commands you want to run as you run manually on MAC terminal.
Follow the below steps :
1. Create a new file, Spotlight | TextEdit or any kind of text editor
2. Enter the commands to run from executable file, for example we will execute below command
echo Running terminal commands from an executable file cd Desktop ls3. Now save the file (Command + s) and name is as Test.command
4. Double click the file that you just saved to execute
Troubleshooting
Sometimes when you double click on the file, you might get some error while executing, so you can give access of “ownership” and set the “execute” on the fileOpen the terminal and enter below command for the file to run,
chmod u+x /path/to/.command/file
Now double click on the .command file, you will see the out put on a terminal with out any error. Thank you for reading this article, and if you have any problem, have a another better useful solution about this article, please write message in the comment section.
No comments:
Post a Comment