Jump to content

Difficulty running Shell (Bash?) script


Recommended Posts

I wrote a few shell (bash?) scripts to simplify some of my tasks in my Kali and Ubuntu Live discs. These were saved as .sh files that could be run when I double-clicked them. I am in the process of writing others for other repetitive tasks

Now that I have updated to Kali 2.0, I cannot run these by double-clicking them. Setting them to run in "Run application" returns a message that says: "unable to locate program"

I have just written a program called script.sh:


echo "Hello World"

And this one has the same difficulties.

They all run in terminal with "sh script.sh", but that defeats their simplicity.

The same problem happens in Kali and Ubuntu, so I don't think it is a Kali 2.0 issue, but it is the first place I noticed the issue.

Permissions are set to run as programs, and the properties tab is checked for "Allow executing file as a program."

Link to comment
Share on other sites

I cannot find that preferences window you have, but I have also tried the chmod +x and some other suggested chmods like 755.

On Kali 1.something, activating the file would give me the option to open in terminal, open in editor, or just run the file. Here in 2.0 and in Ubuntu, I only have the ability to run the file.

Retrying with a new file opens without complaint in "Run Program" but does not produce a result (unless run in terminal with sh script.sh) for:


echo 'hello world' > /root/Desktop/sript_output.txt

If run from terminal, it writes the file as expected, but not in "Run Program" or any other way I can think to "Execute file as program"

Link to comment
Share on other sites

If you can't chmod +x form the console on the file, you could always try the forceful way(if root) of:

bash ./file.sh

which also works when the files are not executable.



​Oh, and try changing #!/bin/bash to #!/bin/sh

Edited by digip
Link to comment
Share on other sites

I attempted the change to #!/bin/sh and everything still runs fine in terminal, but still no luck running them from the file

I would like the functionality I had previously, which is just clicking them to make them run.

Is there another way to open them that I am missing?

The permissions are set correctly

The files work if I use them in terminal

And I try opening them in "Run Software" - I couldn't find any other way to get it to stop opening in gedit or vim

I still get the same message, "Oops! There was a problem running this program. Unable to locate program", even though it is trying to load the one I just right-clicked and told to run.

Link to comment
Share on other sites

The menu in my screenshot is when you open the file viewer and go into the preferences.

Totally missed that, just found it, and it worked a treat -


Had to right click the files icon form the top bar > then behavior > ask

Link to comment
Share on other sites

Wow, it works now, thank you. I had not gone to the top dropdown for "Files Preferences" (I did not realize that actually had more than a list of open folders) and could only find "Properties" in the window itself.

Now everything runs correctly

Edited by cupsdigress
Link to comment
Share on other sites

if you don't want to drop it in your /bin/ you can always do a link between where it is and your command using the ln command

like in kali 2.0 i installed the modded mdk3 https://github.com/soxrok2212/mdk3-master and didn't uninstall the default mdk3

just created a link to the new modded version for my mdk3 command like

ln /root/mdk3-master/mdk3 mdk3

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...