elect
09/20/2021, 11:04 AMsudo
where I have to type the pwd? Shall I directly execute the script itself with sudo
?mbonnin
09/20/2021, 12:30 PMelect
09/20/2021, 12:30 PMmbonnin
09/20/2021, 12:30 PM.kts
is another story, you'll certainly need to fiddle with setuid, whatever sudo is doing under the hoodmbonnin
09/20/2021, 12:31 PMmbonnin
09/20/2021, 12:37 PMProcessBuilder().command("sudo", "whoami").apply {
inheritIO()
}.start().waitFor()
elect
09/20/2021, 12:37 PMprintln(System.`in`.readAllBytes().contentToString())
but the execution gets stuck therembonnin
09/20/2021, 12:38 PMreadAllBytes
will never finish. You'll have to stop reading on a special char like '\n'
for an example (which readLine
is doing)elect
09/20/2021, 12:39 PMreadLine
works flawless indeedmbonnin
09/20/2021, 12:39 PMsudo
, inheritIO
like above is easier than first reading the password and then feeding it to sudoelect
09/20/2021, 12:46 PMinheritIO
and wairFor()
elect
09/20/2021, 12:46 PMephemient
09/20/2021, 5:24 PM-S
, or using JNI to work with pty, but I wouldn't recommend either of thoseelect
09/20/2021, 5:41 PM