Using the automator is possible to execute a shell script that requires input from the user (a password) ? The shell script should be executed in the currently selected folder. I wrote a "Run Shell Script" action like in the following figure:
About the shell actions:
cd $1
~/scripts/pgpsign
First I change to the current selected folder and then I execute my script, that as far as I understand is failing since it requires processing an input before proceeding.
Below the complete code of the script (in Scala)
#!/bin/sh
exec scala "$0" "$@"
!#
import sys.process._
object PGPSign {
def main(args: Array[String]) {
print("Please type passphrase : ")
val passPhrase = readLine()
signFilesInDirectory(new java.io.File("."), passPhrase.toString)
}
def signFilesInDirectory(dir: java.io.File, passPhrase: String) {
if(!dir.exists())
throw new java.io.FileNotFoundException
if(!dir.isDirectory())
throw new RuntimeException("Expecting directory")
println("Signing files in directory: " + dir.getAbsolutePath())
for{file <- dir.listFiles
if !file.isDirectory //ignoring directories
val fileName = file.getName()
if !fileName.startsWith(".") //ignoring hidden files
if !fileName.endsWith(".asc") //ignoring signature files
} {
println("- Signing file " + file)
("gpg -ab --yes --batch --passphrase " + passPhrase + " " + fileName).!!
}
}
}
pgpsign
script, specifically what input it expects? It looks like it's expecting input, but you're not giving it any.