0

I have the following script

#!/bin/bash

VERSION=2020-12-R1
LINK_LIBRERIA=https://github.com/greatscottgadgets/ubertooth/archive/refs/tags/$VERSION.tar.gz
LINK_UBERTOOTH=https://github.com/greatscottgadgets/ubertooth/releases/download/$VERSION/ubertooth-$VERSION.tar.xz


LIBRERIA=libbtbb-$VERSION.tar.gz
## Instalacion de las librerias


SUCESS=1
while [ $SUCESS -eq 1 ]
do
  echo "Select Instalation Directory, left EMPTY for use the actual directory"
  read PATH

  if [ -z $PATH ] 

  then
      PATH=$( pwd )
  fi

  cd $PATH
  SUCESS=$?

done

sudo apt-get -y install cmake libusb-1.0-0-dev make gcc g++ libbluetooth-dev \
pkg-config libpcap-dev python-numpy python-pyside python-qt4 -y

# wget $LINK_BASE_LIBRERIA -O $LIBRERIA
# tar xf $LIBRERIA


When I run it it prompts this:

./main.sh: line 29: sudo: command not found

This probles is the same with the commented commands wget and tar

The ugo priviledges are :

$ ls -l
total 12
-rw-rw-r-- 1 k1k4ss0 k1k4ss0 1064 Mar 27 18:21 LICENSE
-rwxrwxrwx 1 k1k4ss0 k1k4ss0  726 Mar 28 12:31 main.sh
-rw-rw-r-- 1 k1k4ss0 k1k4ss0   81 Mar 27 18:21 README.md

I've tried almost all, but i don't known why, I've searched in internet and look for some scripts with similar commands within, but the problem persist.

3
  • 3
    This is another classic example of why using upper case variables in a script is a disaster waiting to happen. since "$PATH" is an internal variable and all the executables are being search from there if there are no aliases and functions. So you basically set your PATH to something else. You can test it put echo "$PATH" before the read PATH and again after the if clause/statement. Commented Mar 28, 2021 at 11:50
  • 1
    Just to be clear, avoid using upper case variable names if it is just for your script and use shellcheck.net to validate your shell script/code. Also no one can fault/blame you because some books really have upper case varnames and it is all over the internet. Like it works until it doesn't. Commented Mar 28, 2021 at 12:04
  • 1
    ok thaks, problem solved! Commented Mar 28, 2021 at 12:43

1 Answer 1

1

The problems as said in the comments by @Jetchisel is the PATH variable, the interpreter confuses it with the PATH of the global variable, changing it to lowercase solves the problem

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.