Views:
5,479
Votes: 1
✅ Solution
Tags:
command-line
bash
scripts
Link:
🔍 See Original Answer on Ask Ubuntu ⧉ 🔗
URL:
https://askubuntu.com/q/1189182
Title:
How to automate the input of a password, in a custom batch file?
ID:
/2019/11/16/How-to-automate-the-input-of-a-password_-in-a-custom-batch-file_
Created:
November 16, 2019
Edited: November 16, 2019
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
You can take sudo
out of your script and ensure users call the script using sudo scriptname
.
Remove sudo -i
line from your script and replace it with this:
# Must prefix with sudo when calling script
if ! [[ $(id -u) == 0 ]]; then
echo You must call this script using sudo. Aborting.
exit 99
fi