How do I run a script on Linux just by double clicking it

孤者浪人 提交于 2020-06-25 21:06:42

问题


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, type dconf-editor and hit ``Enter.

  • In dconfg-editor goto: org ➤ gnome ➤ nautilus ➤ preferences

  • Click on executable-text-activation and 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!