I use DevOps scripts with SBT script, and I need a task to run the subprocess through sudo, where the user can safely enter their password at the invitation sudo. Is there a way in sbt to allow the subprocess to temporarily still completely capture the console stdinby going through the password key presses up to sudo?
sudo
stdin
You can use the following code in build.sbtor Build.scala:
build.sbt
Build.scala
import sbt.Process val sudo = taskKey[Unit]("Executes commands with sudo!") sudo := { Process("sudo ls /", new File(".")).!< }
"sudo ls /" , , "." , .
"sudo ls /"
"."
, , , , , , .
Sbt Process ProcessBuilder .
ProcessBuilder
Scaladocs !<:
!<
, , , , . . .
, . ProcessIO , .
ProcessIO
, String, File URL ProcessBuilder, Process. , :
String
File
URL
Process
sudo := "sudo ls /".!<
Java- .
SBT, ( ) sudoers, .
Docker SBT.
. build.sbt:
docker := { (test in Test).value (stage in Docker).value "./docker-stuff.sh" ! }
... docker-stuff.sh sudo.
docker-stuff.sh