Okay, I know this is very stupid, but can anybody tell me how to run Java.exe on MAC, LINUX, UNIX? I know how to run it from windows, I have a batch file created in windows, will it work on MAC, LINUX and UNIX as well?
- How To Run Python Script In Mac Terminal
- Run Python Script In Mac
- How To Turn On Java Script In Mac
- How To Schedule A Shell Script In Mac Os X
- Running A Script In Mac
Active1 year, 5 months ago
I have a shell script that has user execution permission on OS X, but when I double click on it, it opens in a text editor. How can I get it to run by double-clicking it?
Jesse Beder22.9k17 gold badges88 silver badges134 bronze badges
- Suppose my java program is HelloWorld.java. We can run it in 2 ways: 1st using executable jar. 2nd by running java class from terminal. Create a new text file and name it hello.sh. In hello.sh!/bin/bash clear java -jar HelloWorld.jar.
- I can make these executable and assign an icon and everything works great except that when I run either of these pseudo programs, either a terminal window or an Applescript icon remains open as long as the application is open.
- How do I run a.sh or.command file in Terminal. Ask Question. Which will also run the executable file with its specified shell (if specified in the shebang #!/bin/(shell). @bart you need to add the.command extension for executing a script within finder directly. – rwenz3l Apr 27 '17 at 9:08.
- Replace /path/to/srcds by the path where you installed the program (the directory where the srcds_run executable is). If you use a Windows editor to edit the script, make sure to tell it to use Unix (LF) line endings; Windows (CRLF) line endings won't work.
5,04912 gold badges40 silver badges54 bronze badges
![How to run python script in mac terminal How to run python script in mac terminal](/uploads/1/3/3/3/133300948/462414172.png)
7 Answers
- First in terminal make the script executable by typing:
- Then, in Finder, right-click your file and select 'Open with' and then 'Other..'.
- Here you select the application you want the file to execute into, in this case it would be Terminal. https://sceneclever118.weebly.com/blog/best-mac-program-for-org-charts. To be able to select terminal you need to switch from 'Recommended Applications' to 'All Applications'. (The Terminal.app application can be found in the Utilities folder)
- NOTE that unless you don't want to associate all files with this extension to be run in terminal you should not have 'Always Open With' checked.
- After clicking OK you should be able to execute you script by simply double-clicking it.
21.8k17 gold badges88 silver badges146 bronze badges
LusLus2,6781 gold badge11 silver badges8 bronze badges
Have you tried using the
HagelinHagelin.command
filename extension? 3d for mac.10.5k5 gold badges25 silver badges37 bronze badges
As of OSX 10.10 (Yosemite) and since at least OS X 10.8 (Mountain Lion), the behavior is as follows when you open (double-click) executable scripts from Finder:
- Executable scripts[1]with either NO suffix or suffix
.command
:- are executed by default - no setup required:
- a new Terminal window opens in which the script runs.
- by default, the window will remain open after the script terminates so you can inspect the output (though at that point the shell that ran the script has exited and you cannot interact with it any longer).
However, via Terminal'sPreferences.. > Profiles
you can opt to automatically close the window when the script exits.
- Caveat: the working folder is invariably the current user's home folder, NOT the folder in which the script is located.
- To make a shell script change to the folder in which it is located, place
cd -- '$(dirname '$BASH_SOURCE')'
right after the shebang line- or, if you must remain POSIX-compliant,
cd -- '$(dirname '$0')'
. - For edge cases, such as finding a symlinked script's true source directory, see this answer of mine.
- To make a shell script change to the folder in which it is located, place
- If the script is unexpectedly not executable:
- Make it executable by running
chmod +x <script>
in Terminal; otherwise, you'll see the following symptoms: .command
: Finder displays a misleading error message that suggests the problem can be fixed viaFile > Get Info
, which is not true - use thechmod +x
method suggested above.- no suffix:
- with a shebang line (e.g.,
#!/bin/bash
): behavior is as if the suffix were.sh
- see below. - with no shebang line: opens in your default text editor (which is TextEdit by default).
- with a shebang line (e.g.,
- Make it executable by running
- are executed by default - no setup required:
- Scripts with suffix
.sh
, whether executable or not:- are opened for editing in
TextEdit.app
or, if installed, withXcode.app
.
- are opened for editing in
- Scripts with suffix
.scpt
or.applescript
(even if they're themselves marked as executable, which is not normally the case):- opened for editing in
[Apple]Script Editor
- Note that the JXA source-code files seem to have no distinct suffix (yet).
- opened for editing in
- Scripts with a custom suffix (a suffix not yet known to the system), whether executable or not (in fact, applies to any kind of file):
- prompt you for the app to open them with when you first open them, and remember that choice.
[1] Executable means: a script with the executable permission bit(s) set and the calling user - relative to the ownership to the file - therefore potentially being allowed to execute it.
If you use
mklement0mklement0If you use
chmod a+x
to set all permission bits (which is typical), anyone can invoke it (assuming they're also allowed to read the file based on the read permission bit(s) and the file's ownership). Free drawing program for mac.How To Run Python Script In Mac Terminal
156k26 gold badges276 silver badges321 bronze badges
Alternatively, you could create a regular Mac OS X application from your script using Platypus
svthsvth1,1141 gold badge13 silver badges20 bronze badges
The easy way is to change the extension to
.command
or no extension.But that will open the Terminal, and you will have to close it. If you don't want to see any output, you can use Automator to create a Mac Application that you can double click, add to the dock, etc.
- Open
Automator
application - Choose 'Application' type
- Type 'run' in the Actions search box
- Double click 'Run Shell Script'
- Click the
Run
button in upper right corner to test it. File > Save
to create the Application.
Run Python Script In Mac
14k6 gold badges71 silver badges61 bronze badges
No need to use third-party apps such as Platypus. Easy editing program for mac.
Just create an Apple Script with Script Editor and use the command
do shell script 'shell commands'
for direct command calls or executable shell script files, keep the editable script file safe somewhere then export it to create an Application script. the app script is launch-able by double click or selection in bar folder.How To Turn On Java Script In Mac
mklement0156k26 gold badges276 silver badges321 bronze badges
How To Schedule A Shell Script In Mac Os X
Luc-OlivierLuc-Olivier
![Executable Executable](/uploads/1/3/3/3/133300948/589904082.png)
You can also set defaults by file extension using RCDefaultApp:
potentially you could set .sh to open in iTerm/Terminal etc. it would need user execute permissions, eg
Running A Script In Mac
TomachiTomachi