0

I am trying to run script a from script b, I didn't create script a and I am not sure if i want to add script as location to PATH.

Making things even more hard to do is the fact I want to run script a with sudo, but not script b so I have whiptail in script b to ask for password and pass along with echo $pass | sudo -S.

my current code:

#!/bin/bash
input=$(whiptail --passwordbox "Enter password" 10 50 3>&1 1>&2 2>&3 )
echo $input | sudo -S bash /home/<username>/multibootusb/makeUSB.sh -e -b "$1" "$2"
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
HackerNCoder
  • 276
  • 1
  • 9
  • Everything looks good, what's wrong?) – Ivan Jan 20 '20 at 13:59
  • See also [When to wrap quotes around a shell variable?](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable/27701642) (Hint: This is one of those situations.) – tripleee Jan 20 '20 at 14:00
  • And you can use `read` instead of `whiptail` like so `read -s -p 'Enter password ' input` – Ivan Jan 20 '20 at 14:04
  • 1
    Why prompt for the password yourself? `sudo` will prompt for a password if one is required. – John Kugelman Jan 20 '20 at 14:16
  • @Ivan. It doesn't work. sudo says it can't find it – HackerNCoder Jan 20 '20 at 20:39
  • @tripleee Seems to be so. I'm a bit new to bash, where would I put it? – HackerNCoder Jan 20 '20 at 20:39
  • Read the page I linked, In brief, quote everything unless you specifically want the shell to perform whitespace tokenization and wildcard expansion on a value. (Hint: The password could very well contain shell metacharacters.) – tripleee Jan 21 '20 at 05:20

0 Answers0