2

I have a simple script that I want to be able to run by double clicking a text file and having it run in terminal so i don't have to do it manually

#!bin/bash
$ cd /home/tyler/df_linux
$ ./df

I've tried "allow executing file as program" but the file still opens in gedit.

I've also used sudo chmod +x df while in the directory, terminal asks for my password, i enter it, and then nothing happens.

I've been looking around the internet and my problems are similar to that of if my HDD was NTFS format, i checked using sudo blkid -o list > ~/myFileSytems and I can see that the script I'm trying to run is in an ext4 partition; so, that isn't the issue.

I've been looking around the internet all day and have found people with similar problems but none of the solutions that I have found have worked.

My question was marked as a duplicate of How do I run executable scripts in Nautilus? and i do not understand why, my problem has nothing to do with nautilus and i cannot seem to find any program called nautilus on my computer.

I am running Ubuntu 14.04.03 and I am trying to run my script in terminal, I am using hashbang and the color of the text in my script has changed to identify that linux understands that it is a script, but the script will not run when I double click the file.

Tyler
  • 51
  • Have you checked if you have a shebang? – edwinksl Jul 09 '16 at 02:36
  • 4
  • @FlorianDiesch i saw that question and none of the anwsers in it worked for me.

    edwinksl sorry for my ignorance but i am unaware of what a shebang is, im still rather new to linux

    – Tyler Jul 09 '16 at 02:40
  • @Tyler Can you perhaps add to your question what your script contains if it isn't excessively long? – edwinksl Jul 09 '16 at 02:48
  • @edwinksl the OP already contains the script, essentially what it does is run another script thats in an inconvenient location that launches the program. the second script is as fallows: #!/bin/sh DF_DIR=$(dirname "$0") cd "${DF_DIR}" export SDL_DISABLE_LOCK_KEYS=1 # Work around for bug in Debian/Ubuntu SDL patch. #export SDL_VIDEO_CENTERED=1 # Centre the screen. Messes up resizing. ./libs/Dwarf_Fortress "$@" # Go, go, go! :)

    this script came with and launches the game "dwarf fortress"found here:http://www.bay12games.com/dwarves/ that script wont run on double click either

    – Tyler Jul 09 '16 at 02:53
  • 1
    @Tyler when you post code in the comments it is hard to read , because it's all jammed up. Use paste.ubuntu.com , post the contents, then provide link here. One thing that I've noticed is that you are calling ./libs/Dwarf_Fortress "$@" This is calling Dwarf_Fortress with command line parameters given to the script. In your example posted above, you only call ./df and no arguments ; what is expected is something like ./df one_arg second_arg . I'd like to help you troubleshoot the stuff , so let me know once you post it to the pastebin site or find me in the askubuntu chat – Sergiy Kolodyazhnyy Jul 09 '16 at 03:06
  • 1
    @FlorianDiesch This question is not a duplicate. OP clearly knows how to run scripts and he even allowed it in the Nautilus. Please retract your close vote, as the issue here is different . Potentially there is a syntax error of sorts – Sergiy Kolodyazhnyy Jul 09 '16 at 03:07
  • 1
    *CLOSE VOTERS Please retract the votes, as the issue here is very different from the suggested duplicate. OP clearly knows how to run scripts and allow them in file manager. – Sergiy Kolodyazhnyy Jul 09 '16 at 03:08
  • http://paste.ubuntu.com/18854654/ this script (script #1 as it runs first) was created by me. the first line tells terminal to look in the correct directory, the second line causes script #2 to run.

    http://paste.ubuntu.com/18854513/ script #2 (as it runs second) this script was not created by me and was included with dwarf fortress, the script does its job and launches the intended program.

    when i run the commands in script #1 in terminal manually it works properly and runs script #2, which then launches my game. therefore i know the code works. the issue is -> next comment

    – Tyler Jul 09 '16 at 03:14
  • script #1 to run when i double click on the icon for it on the desktop

    i have to step away from the computer for the night unfortunatly

    – Tyler Jul 09 '16 at 03:14
  • 2
    What you've posted doesn't appear to be a valid script (1) #!bin/bash isn't a valid interpreter (it needs to be #!/bin/bash - note the leading slash) and (2) you appear to have included shell prompts $ at the start of each command. Until you can execute it in a terminal using ./scriptname it is pointless trying to get it to run as a double-click executable. – steeldriver Jul 09 '16 at 03:25
  • @steeldriver ive edited the script and i can get it to run via ./scriptname so now we know for sure that the script works. – Tyler Jul 09 '16 at 14:51

1 Answers1

0

Using Thunar (XFCE): https://bbs.archlinux.org/viewtopic.php?id=194464

Using Dolphin (KDE): http://ubuntuforums.org/showthread.php?t=1882254

Please post what file manager you are using.

EDIT: Script #1's lines appear to have $s before them. Remove those.

Aly
  • 265
  • I tried both and the instructions for dolphin worked! I'm now able to launch my program by double clicking on the script. – Tyler Jul 09 '16 at 15:16