Bash script - Automatically enter user input (password of keystore)
You could use expect utility to automate your passphrase input. Create launcher script auto-jar.sh
:
#! /usr/bin/expect
# Wait for finish forever after send password
set timeout -1
# Put your jarsigner command here
spawn jarsigner ...
expect "Enter Passphrase for keystore: "
send "your jar password\r"
# Wait for jarsigner command finish
expect eof
# Return relevant exit code of jarsigner command
# , useful if you want continue next command only after signed successfully with `&&`
foreach {pid spawnid os_error_flag exit_code} [wait] break
exit "$exit_code"
Then chmod +x auto-jar.sh
to make it executable and run with ./auto-jar.sh
. Or run as expect auto-jar.sh
.
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I know this has been asked before but almost only workarounds have been provided. None that solved my problem just yet.
I'm trying to create my own
.sh
file which will generate anapk
. After using jarsigner it asks for a password of my keystore. Now the security on this part doesn't play a role a.t.m. so I was just wondering, how can I (either remove the password of my.keystore
file or enter the password as plain text) achieve this?The full command:
jarsigner -sigalg SHA1withRSA -digestalg SHA1 -verbose -keystore keyForApk.keystore apk/android-release-unsigned.apk alias_name
Where it then prompts me the following:
Enter Passphrase for keystore:
Now via which command can I enter this dynamically after the jarsigner command?
-
Admin over 7 yearsI'm not familiar with jarsigner, but it's possible that it's trying to directly read your terminal; test it out with
echo | jarsigner -sigalg .... rest of it
-
Admin over 7 yearsfor testing you can provide passwords in the command line with options
-storepass
and-keypass
. seeman jarsigner
.
-
-
canbax almost 5 years"spawn" is not found. I installed expect and "expect" is found