1

I'm trying to make a script to mount a disk when runned. The script is

#!/bin/bash
PATH=$(python /home/pi/prova.py 2>1&)
sudo mount $PATH /media/Drive1

where path in our case is /dev/sda1 (checked using echo).

The error reported is ./script.sh: line3: sudo: command not found

the script is added to /etc/sudoers using line

 pi ALL=NOPASSWD: /home/pi/script.sh

The error is the same both adding and removing the sudo before mount command.

Any idea ? Thanks in advance

Barmar
  • 741,623
  • 53
  • 500
  • 612
Uge
  • 63
  • 2
  • 5

1 Answers1

1

Don't use all-upper-case variable names for regular shell variables. This avoids overwriting environment variables and shell builtins (such as PATH, used by the shell to determine where it looks for external commands) by mistake.

Thus, a corrected implementation of this script may be:

#!/bin/bash
path=$(python /home/pi/prova.py 2>1&)
sudo mount "$path" /media/Drive1
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441