.sh files not opening in terminal

Linux for blind general discussion blinux-list at redhat.com
Thu Dec 9 16:34:09 UTC 2021


>From context, I'm guessing you're trying to open them from a graphical
file manager instead of trying to run them in a terminal emulator or
from the console.

I haven't used a graphical file manager in close to a decade, but part
of me says clicking on a script file and it opening in an editor
should be the expected behavior.

The usual way of running a script is to open a terminal emulator(if
using a graphical desktop), change to the directory the script is in,
and typing:

./scriptName.sh

This assumes that the script contains the appropriate shebang line(a
line beggining with a pound sign and exclamation mark, followed by the
path to the appropriate interpreter(e.g. /bin/bash for bash scripts)
and the user has execute privileges on the script. if either of these
are missing, you need to invoke the appropriate interpreter with the
script as an argument(e.g. bash scriptName.sh for a bash script
without the correct shebang line or permissions).

That said, it's possible the graphical file manager you're using might
have run, execute, or something similar in its context menu... though
depending on what the script does, this might result in a terminal
window opening, printing output, then closing before you can read the
output.

Also, if you have a bunch of scripts with the correct shebang line and
execute permissions, you can put them all in a folder, add that folder
to your path, and then run any script in that folder in a terminal
emulator from anywhere in the directory tree by typing

scriptName.sh

Which can be done by adding the following to ~/.bash_profile:

export PATH=/path/to/user/scripts:$PATH

Which I'll admit to not truly understanding since I added it to my own
~/.bash_profile months, if not years ago and its the kind of thing you
set then forget how its done until you have to do it again.




More information about the Blinux-list mailing list