I name it "showpath" but some would add the extension ".sh" and claim it to be safer:
Code: Select all
showpath.sh
Code: Select all
#!/bin/bash
echo $PATH >> ~/PATH_log.txt
date +Kl-%R-%d-%b-%Y >> ~/PATH_log.txt
echo "" >> ~/PATH_log.txt
featherpad + ~/PATH_log.txt
It will create the file "~/PATH_log.txt" and add the PATH and time to it and open it with Featherpad, so you can see it and compare to the last time you did it. And you can add a comment if you want.
If you prefer an other editor you can just edit the last line.
For instance a command for Gedit is very similar:
Code: Select all
gedit + ~/PATH_log.txt
How to use.?
In user friendly scripting a scriptor must have his PATH under full control, so I choose always to have an icon for it in my panel.
And if I ever have doubts about if PATH is working correctly in Terminal I just execute the command "showpath.sh" in Terminal.
It shows what the PATH is not before or after but in the very moment when the script is actually running.
If you use Xfce, and you have a directory for your personal scripts I can recommend a test. Especially with the command "showpath.sh" put into a desktop program launcher, and also one in the Panel. Then you can start easy testing from different locations. From desktop, from Panel, from Terminal, when Live, from another user profiles, and where else you might want.
Afterwards you perhaps decide to reconfigure PATH and/or move the script to another directory and try it all over again.
The script is still pure code just made for testing.
In case more explanation is demanded I will do my best to supply. :-)
****Edit:
On basis of the discussion, and in order to promote a user friendly MX script culture, I have upgraded the script with a help sequence, more text, and output from "whereis" is being added to the log file:
Code: Select all
#!/bin/bash
# This script is a testscript for finding script location and PATH and log it in a file that is automatically opened by Featherpad showing the result.
# The script is a user built in MX-Linux 23
# Ref. https://forum.mxlinux.org/viewtopic.php?p=822108#p822108
# Ref. script template: https://forum.mxlinux.org/viewtopic.php?p=725990#p725990
# Main sequence begin
case $1 in
# Subsequence begin
'show'|'run')
# Sending empty line to ~/PATH_log.txt
echo "" >> ~/PATH_log.txt
# Sending output from "whereis" to ~/PATH_log.txt
whereis "${0##*/}" >> ~/PATH_log.txt
# Sending info, date and time to ~/PATH_log.txt
date +'Execution moment: '%R-%d-%b-%Y >> ~/PATH_log.txt
# Sending PATH to ~/PATH_log.txt
echo $PATH >> ~/PATH_log.txt
# Sending empty line to ~/PATH_log.txt
echo "" >> ~/PATH_log.txt
# Open ~/PATH_log.txt with Featherpad going to end of file
featherpad + ~/PATH_log.txt
;;
# Subsequence end
# Subsequence begin
'help'|'-h'|'-help'|'--help'|'-?'|'--?'|'/?')
clear
echo "Purpose: - Showing and logging PATH"
echo "Create ~/PATH_log.txt - put PATH in it and open it with Featherpad"
echo "Test for script PATH at chosen location when script is running"
echo 'If needed there is more info. inside the script'
echo "Syntaks: ['${0##*/}'] [Argument]"
echo ''
echo ''
echo 'Arguments:'
echo ' --help This help text'
echo ' show Send PATH to ~/PATH_log.txt and open with Featerpad'
echo ''
echo 'Exampels:'
echo ' "'${0##*/}' --help" Show this help'
echo ' "'${0##*/}' show" Run the test'
;;
# Subsequence end
# Below this line you will find commands that are used if no argument has previously been recognized.
*)
# The next line will make the script run 'show' even without the argument
"${0##*/}" show
# If deactivated it might be relevant instead to activate this line:
# echo ' Write "'${0##*/}' --help" for help'
;;
# Above this line you will find commands that are used if no argument has previously been recognized.
esac
# Main sequence end