2
When I follow the steps in 

[https://askubuntu.com/questions/138908/how-to-execute-a-script-just-by-double-clicking-like-exe-files-in-windows]

I used to get a dialog box asking whether I wanted to execute the shell script or edit it using gedit. I just reinstalled Ubuntu Linux 16.04 with a LiveCD and ran sudo apt-get install mono-complete. Now , when I double click the shell script in Ubuntu 16.04 Nautilus I only can edit the shell script file.

The contents of this shell script are:

#!/bin/bash
exec /usr/bin/mono-service.exe ./AudioRecorder.exe  "$@".

as specified in 

  [http://www.mono-project.com/archived/guiderunning_mono_applications/]

Why is this problem occuring and how do we fix it so double click the shell script in Nautilus asks me if want to execute the shell script file?

Any help is greatly appreciated.

6
  • I think you are looking for this instead askubuntu.com/questions/286621/…
    – mchid
    May 28, 2016 at 5:22
  • @mchid , Thank you for your excellent comment. I just read the URL you told me to read: askubuntu.com/questions/286621/…. May I ask where the Nautilus menu bar is on Ubuntu Linux 16.04 installled from a LiveCD?
    – Frank
    May 28, 2016 at 7:33
  • It should show when you bring the mouse up over the top bar (unity panel) when nautilus is maximized. If it does not, you can press ALT and then type preferences and press enter.
    – mchid
    May 28, 2016 at 7:42
  • @mchid, Thank you for your complete answer. If I press ALT , do I type the entire word preferences and then press enter?
    – Frank
    May 28, 2016 at 7:53
  • Yes. Also, you could click on the result "preferences (edit)" that pops up if you don't want to keep typing. Alternatively, you should be able to get away with typing "pref" and pressing enter. You must do this when nautilus is open and is the current window.
    – mchid
    May 28, 2016 at 7:56

2 Answers 2

2

First of all, /usr/bin/mono-service.exe does not exist.

Next, according to your posted link. Your script should read something like this:

#!/bin/sh
/usr/bin/mono /usr/lib/mono/4.5/mono-service.exe ./AudioRecorder.exe  "$@"

or

#!/bin/sh
/usr/bin/mono-service ./AudioRecorder.exe  "$@"

or

#!/bin/bash
mono ./AudioRecorder.exe  "$@"

or

#!/bin/sh
/usr/bin/mono ./AudioRecorder.exe  "$@"

However, these will only work if the exe file is in your home folder and ideally should include the actual path to the exe file such as the following if the exe file is in your home folder:

#!/bin/sh
/usr/bin/mono /usr/lib/mono/4.5/mono-service.exe ~/AudioRecorder.exe  "$@"

or

#!/bin/sh
/usr/bin/mono-service ~/AudioRecorder.exe  "$@"

or

#!/bin/bash
mono ~/AudioRecorder.exe  "$@"

or

#!/bin/sh
/usr/bin/mono ~/AudioRecorder.exe  "$@"

Alternatively, if the file is in your Downloads folder:

#!/bin/sh
/usr/bin/mono /usr/lib/mono/4.5/mono-service.exe ~/Downloads/AudioRecorder.exe  "$@"

or

#!/bin/sh
/usr/bin/mono-service ~/Downloads/AudioRecorder.exe  "$@"

or

#!/bin/bash
mono ~/Downloads/AudioRecorder.exe  "$@"

or

#!/bin/sh
/usr/bin/mono ~/Downloads/AudioRecorder.exe  "$@"
6
  • I just accepted your great answer. Why do I have to put /usr/bin/mono or /usr/bin/cli before /usr/lib/mono/4.5/mono-service.exe? When did you leave out exec before /usr/bin/mono /usr/lib/mono/4.5/mono-service.exe ~/AudioRecorder.exe "$@"? When I run exec /usr/lib/mono/4.5/mono-service.exe ~/AudioRecorder.exe , why does ps -ef and top put a /usr/bin/cli before /usr/lib/mono/4.5/mono-service.exe ~/AudioRecorder.exe. You should go for a Ph.D in computer science part-time. I wish I had done that.
    – Frank
    May 28, 2016 at 7:40
  • @Frank 1 Because you can't run or execute an exe file on ubuntu, you would need to have wine or mono execute an exe for you. 2 Exec= is not the same as exec and I don't know much about that command so I'm not sure. 3 I should probably finish engineering first, thanks.
    – mchid
    May 28, 2016 at 7:53
  • @Frank Also, /usr/bin/cli is a symbolic link to /etc/alternatives/cli which is a symbolic link to /usr/bin/mono which is a symbolic link to /usr/bin/mono-sgen if that helps.
    – mchid
    May 28, 2016 at 8:13
  • Thank you for your professionalism. Good luck with engineering and computer science Ph.D, The future of software engineering belongs to those with advanced degrees in computer science. May I ask the best way to reach you on Stack Exchange for linux questions?
    – Frank
    May 28, 2016 at 13:13
  • @Frank Just ask your question whenever you have one; there will almost always be someone on here who can answer them.
    – n.st
    Jun 1, 2016 at 8:55
0

Here is the URL I found which answers the question.

Double click Linux Bash Script and debug with pause commands

@terdon's answer is really nice:

Your script needs a terminal for you to interact with it. One way of doing that is what @Sebastian suggested. However, note that bash scripts are not really designed to be run this way. A cleaner way would be to write a .desktop file that launches your script and then double click that. Something like:

[Desktop Entry]
Exec=/home/user/yourscript.sh
Terminal=true
Type=Application

Save that file as foo.desktop in your ~/Desktop folder. That will now appear as an icon there and double clicking it will cause your script to be run in a terminal. Obviously, you need to change /home/user/yourscript.sh to the actual path of your script.

One question remains open: With @terdon's emulator, how can I redirect stdin, stdout and stderr to /dev/null?

[EDIT June 2 2016 4:30 A.M. The way to redirect stdout and stderr is to exec mono-service ./AudioRecorder.exe & , ine the background]

1
  • This answer should be disregarded from now on . In it's place, please look at this URL, unix.stackexchange.com/questions/286838/…. Please let me know if you have questions since this new solution is not "mechanical" cut and paste.
    – Frank
    Jun 2, 2016 at 15:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .