[xubuntu-users] Not able to execute .sh files

Ralf Mardorf ralf.mardorf at rocketmail.com
Mon Nov 30 07:08:43 UTC 2015


On Sun, 29 Nov 2015 22:42:59 +0000, Michele Mor wrote:
>If I type in terminal: spoon.sh, then I have "spoon.sh: command not
>found". If I type in terminal: ./spoon.sh, then everything works OK.
>
>My question is then: why does it work using ./ ?

./ is the path
  ls -l ./
if you type it without the path it's expected to be in a path for
executable, such as /usr/local/bin/, so you either need to type the
path or to run a command such as cat, ls or bash before you can add the
script name without he path or you need to move or copy it to a path
for executables.

Open a terminal and type
  cat spoon.s
then type the tab key, you'll notice that auto-completion will work.

Type the path e.g.
  /home/me_myself/spoon.s
  ~/spoon.s
  ./spoon.s
then type the tab key, you'll notice that auto-completion will work.

Type
  spoon.s
then type the tab key, you'll notice that auto-completion will
_not_ work.

Type
 xfce4-termina
then type the tab key, you'll notice that auto-completion will work.

Copy it to a path for executables
  sudo cp spoon.sh /usr/local/bin
Type
  spoon.s
then type the tab key, you'll notice that auto-completion will work and
that you can execute the script.

[rocketmouse at archlinux ~]$ cat demo-script.sh 
#!/bin/bash
echo "hello world"
exit
[rocketmouse at archlinux ~]$ demo-script.sh
bash: demo-script.sh: command not found
[rocketmouse at archlinux ~]$ /home/rocketmouse/demo-script.sh 
hello world
[rocketmouse at archlinux ~]$ bash demo-script.sh 
hello world
[rocketmouse at archlinux ~]$ sudo cp demo-script.sh /usr/local/bin/
[rocketmouse at archlinux ~]$ demo-script.sh
hello world

Regards,
Ralf





More information about the xubuntu-users mailing list