Can not run script that is in my $PATH

My Script directory is in my path, yet I can not run scripts from other directories ?

andy@7:~$ echo $PATH
/root/MUSIC/:/root/Scripts/:/root/MUSIC/:/root/Scripts/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

andy@7:~$ dir Scripts
30_VOL.sh Blank.sh Doorbell_Sound.sh FsArchive_Hard_Drive.sh Icons.sh move.sh Print_JSC_Chk_Register.sh Scripts_Dir.sh timer.sh writer.sh
50_VOL.sh CleanUp.sh Downloads_Dir.sh Home_Andy.sh IMPT_Ubuntu_Tips.sh Non_Admin_Thunar.sh PW_Generator.sh sea.sh Ubuntu_Scripts.zip
arrange_dt.py CX7_Maintenance.sh Drive_Temp.sh HopeJournal.sh Kill_ALL_Windows.sh On_host.sh Reboot.sh Shutdown.sh vol
Backup_AMD.sh Documents.sh File_System.sh Icons_Dir.sh Maxtor_Backup_Dir.sh Print_Beacon_Chk_Register.sh Scanner.sh SUPER_THUNAR.sh volume.rb

andy@7:~$ ./CleanUp.sh

bash: ./CleanUp.sh: No such file or directory

/root/Scripts ?
I don’t think your regular user can read this.

There’s no need to place “./” before the script name if it’s containing directory is in the current PATH.

The “./” forces it to look current directory only.
/root is not a place I’d recommend.

There’s a pretty standard place to put “personal” scripts/programs in your home directory at ~/bin. A standard user login script sees this directory and automatically adds it to $PATH. All you need do it stick 'em in there and make them executable. This goes way back in Linux.

Even with ./, it still does not work.

Problem with putting scripts in /bin is there are mixed up with other non script files.

My Scripts directory has nothing but my personal bash scripts which makes file keeping easy.

That’s ~/bin, not /bin.
/home/(username)/bin.

mkdir ~/bin
logout/login (1st time only)
Everything is ready.
Add executable scripts to ~/bin
Execute with only the script name from anywhere.

1 Like

@fixit7 - Also, your dir Scripts command lists the CleanUp.sh script as being inside the Scripts folder, but you’re running it from the current directory.
Assuming that the /root/Scripts thing is correct (which is weird anyway), try running it like

./Scripts/CleanUp.sh

Edit: I reread the original post, and yeah, I think just removing the ./ should work. Also make sure your script is executable. However, I agree with the rest that using ~/bin is the right way to go

This is the correct location for personal script files. Well stated @Bill_MI :+1:

2 Likes

I get it now.

I created /home/andy/bin and put the script there.

It runs from any dir now.

2 Likes

Great! Since you’re familiar with $PATH you can verify it gets added.

That “./” is specific in a lot of procedures but depends on the directory you are in at the time so NOT universal. In fact it bypasses $PATH. Just wanted to clarify.

1 Like

Thanks.

That dir got added.

Seems odd you’ve been asking about paths for over a year now, and are still having problems:
https://www.linuxquestions.org/questions/linux-newbie-8/script-directory-in-path-4175571740/

Read my 2nd to last post. Problem is solved.

I did. Whole thread is odd, since you’ve been working with/asking about PATH’s for over a year.