Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 6391  / 3 Years ago, sat, october 30, 2021, 1:23:50

After reading an answer on how to make a file run a command in the terminal when ran, I tried to do it myself.



I made a new document, entered the following and saved.



#! /bin/bash

echo "this is a test"


I then went to Right-Click > Properties > Permissions and checked "Allow executing file as program."



However, when I double-click the document, it simply opens in my text editor (which I believe is gedit). In the right-click menu I see no options for running the file in the terminal.



I've tried doing this with other files as well. For instance, I installed WINE and tried to install a Window's program. WINE said to simply run the installer, but nothing would happen when I tried. I marked it to run as a program and still it wouldn't work. I could only install it by Right-Click > OpenWith and selecting WINE.



Strangely enough, I copied my Keepass-2.28 Portable folder from my Windows partition to my Ubuntu partition and tried running the executable. Keepass fired right up, even though I hadn't marked that file to run as a program. I have Keepass 2.25 from the repository installed on my system if that makes a difference.



I've been running Ubuntu 14.04 in a dual-boot setup for several weeks. The only thing I can fathom I did that would mess this up is I used Synaptic Package Manager to remove a package from KDE Desktop Environment in an attempt to uninstall an alternate desktop environment I installed via the terminal. I don't remember what the package was, but the only package in that category right now is appmenu-qt5. As far as I can tell, removing that package has affected nothing, and I'm pretty sure I had issues with running files as programs since I got my Ubuntu.



EDIT: I have checked, and I don't think this question is a duplicate of this question. My Ubuntu is on a ext4 partition, and it's from there I'm trying to run programs. I also haven't dealt with trying to change permissions via the terminal or anything like that, I'm just trying to make the program run when I check the option in the properties menu. Please correct me if I'm wrong or missing anything.


More From » scripts

 Answers
4

Help in Right-Click > Properties > Permissions explains this behavior:




If the file is a program, such as a script, you must select Allow
executing file as program to run it. Even with this option selected,
the file manager may still open the file in an application or ask you
what to do. See Executable text files for more information.




The default action when double-clicking a script is to open it in the editor. To change this option:




  1. Click Files in the Launcher, select Edit > Preferences and then the Behavior tab:



    enter image description here


  2. Select the default action when opening an executable text file:




    • Run executable text files when they are opened

    • View executable text files when they are opened

    • Ask each time




"Ask each time" is probably the right setting here, as you certainly don't want to accidentally execute a script when you just want to open a text file, especially since executable and non-executable text files share the same icon.


[#20965] Sunday, October 31, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ronicod

Total Points: 71
Total Questions: 111
Total Answers: 111

Location: Montenegro
Member since Fri, Dec 10, 2021
2 Years ago
;