问题
I have a script written (which are basically the commands for the terminal for Ubuntu) on a file. Yes, the code starts with
#!/bin/bash
How do I run this script just by double clicking it? It can be run using the terminal but I want to make it more accessible through my desktop.
I was just trying to mimic a *.bat file on windows. A *.bat file on windows contains series of scripts operable on command prompt and executable just by double clicking on it.
回答1:
Follow these steps:
Hit
Alt+F2, typedconf-editorand hit ``Enter.In dconfg-editor goto:
org ➤ gnome ➤ nautilus ➤ preferencesClick on
executable-text-activationand from drop down menu select:
launch: to launch scripts as programs.
OR
ask: to ask what to do via a dialog.
Close dconf-editor Thats it!
回答2:
Source https://askubuntu.com/a/286651/113065
Edit -> preferences -> Behavior -> Executable Text Files = Run ...
It should run, but you can't see output.
回答3:
You need to make it an executable file, either use chmod +x <filename> or go into the file properties and set it there.
来源:https://stackoverflow.com/questions/42044798/how-do-i-run-a-script-on-linux-just-by-double-clicking-it