I have a bash script named Script.sh . It worked well when it was in my /home directory.I moved it to my /bin directory,for running it as command. At first it worked well(as a command, in my /bin), but after restarting, it stopped working. When I type Script.sh , in terminal, nothing happens and I have to use Ctrl+C for getting the terminal to work again. When my Script.sh is in my /bin, my spd-say command doesn't work either(it does not pronounce the argument when I use it in terminal). After moving the script from /bin, everything gets corrected. Is there any problem, moving a file to /bin?
$ echo $PATH
:/home/m/bin:/home/m/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/binThis is the first part of the script.
#!/bin/bash
spd-say -w "Do you know this man?"
xdg-open $(locate "X.jpg")
read a
if [ "$a" == "yes" ]
then
spd-say -w "Call the police."
else
spd-say -w "Thanks."
fi 12 1 Answer
I have not enough reputation to make a comment, but it seems to me that you need to put your script in /usr/local/bin.
From man hier(7)
/bin This directory contains executable programs which are needed in single user mode and to bring the system up or repair it. /usr/local/bin Binaries for programs local to the site.
You know, copy with sudo cp and check the permissions.
But if you want to use the program just for yourself, put in on /home/$USER/bin folder.
Also, you can make a symlink from your script to a path in /usr/local/bin
ln -s /full/path/to/your-script.sh /usr/local/bin/<empty or optional name>