1

I hope that my post is acceptable although I am actually running lubuntu, not ubuntu.

I am trying to create an executable file but I am having difficulties.

I created a script with a text editor and saved it onto my desktop:

#!/usr/bin
echo hello

I ran sudo chmod +xand sudo chmod 755 on it. When I double click on it I get a dialogue box asking me either to execute or execute in terminal as follows:

enter image description here

When I click on execute, I get Failed to execute child process "/home/name/Desktop/helloworld" (Permission denied)

If I click on execute in terminal, I just get a new terminal window with name@macbook:~/Desktop$ but no sign of my script.

2
  • 1
    Why is your shebang #!/usr/bin? ..please read this
    – heemayl
    Mar 14 '15 at 20:55
  • Just tested this, file named as test.sh with #!/bin/bash as first line. Works fine from command line. Are you actually trying to create a GUI-executable (icon)?
    – david6
    Mar 14 '15 at 21:21
1

This is most likely caused by your Shebang - the #!/usr/bin line in your script.

The Shebang in a script is what tells Ubuntu/Linux/BASH what command to run to interpret or execute the script.

Python script shebangs are usually #!/usr/bin/env python or #!/usr/bin/python (says to run the script with the Python interpreter) and BASH scripts (like yours is) are usually #!/bin/bash (says to run the script in a BASH terminal) or #!/bin/sh (run the script with sh or shell).

Because /usr/bin is a directory, not a program/sym-link to a program, nothing can actually be executed.

Try changing that initial line to be #!/bin/bash:

#!/bin/bash
echo hello
6
  • Sadly nothing has changed except that clicking on execute now does nothing, not even give an error.
    – Nick
    Mar 14 '15 at 21:06
  • @Dr.Paul That's because you're running the echo command, which only outputs to the terminal. Try changing the echo Hello line in your script to `notify-send "Hello!" "Hello There!". It'll display a notification. Look here for more explanation on how to send custom notifications. Mar 14 '15 at 21:09
  • 2
    One point, python uses #!/usr/bin/python or #!/usr/bin/env python
    – heemayl
    Mar 14 '15 at 21:10
  • @heemayl True. I've always used the #!/usr/env/python one, couldn't remember what the other correct one was. Edited, thanks for pointing that out :) Mar 14 '15 at 21:11
  • Are you sure? there is no env directory in /usr so no question about /usr/env/python..
    – heemayl
    Mar 14 '15 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.