By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Bash script for diagnosing problems with running software inside of terminal


Legendary Coder
This script is actually kinda unnecessary on a linux system because you just have to try running a program through the terminal in order to figure out that you haven't installed it:

kerblunk: command not found

However, if you are looking for more information, then this script might be able to lead you figuring out problems sooner:

#script idea: tell user if a file is executable or is included in path


if [ $# -lt 1 ]; then
        echo "Usage:${SCRIPT##*/} [program-name]"

#creates file listing path directories
echo $PATH | awk 'BEGIN {RS=":"} {print}' | sed '/^$/d' > path-dirs

#loops through directories and tells user if file exists but is not executable
while read -r line; do
    if [ -f "$line/$1" ] && ! [ -x "$line/$1" ]; then
                echo "$1 is in \$PATH but is NOT executable"
                echo "Location: $line"
                exit 0
done < path-dirs

#tells user program is ready to use
while read -r line; do
    if [ -x "$line/$1" ]; then
                echo "$line/$1 is in \$PATH and is executable"
                echo "Location: $line"
                exit 0
done < path-dirs

rm path-dirs

#program does is not in path
echo "$1 does not exist in \$PATH"

I used the "while read" concept here, but "readarray" is potentially better and less deprecated.

New Threads

Buy us a coffee!

Top Bottom