How to enforce interactive keytool?

i am reading line by line from a file as below

while IFS= read -r var
do
...
...
...
done < "hello.txt"

I added the keytool command in the do while loop as below.

while IFS= read -r var
do
...
keytool -genkey -alias $fname -keyalg RSA -keystore $fname.jks -keysize 2048
...
done < "hello.txt"

But instead asking user to input the details the keytool is reading input from hello.txt and fails with the below error.

Can you help me fix this problem ?

while read LINE
do
        something-that-needs-terminal < /dev/tty
done < inputfile

I'm a little surprised keytool doesn't do this automatically, though. Usually things that read passwords absolutely insist on using the terminal. But if it's a bulk generation tool it makes sense.

1 Like

Well, yes, you redirect stdin from "hello.txt", and keytool reads from stdin (c.f. man keytool )... Try opening "hello.txt" on another file descriptor.

Thank you @Corona .... Resolved.

1 Like