Reputation: 135
This script statements in certmgmt.sh-
update_keystore(){
keystore_file_path="/data/cert/keystore.jks"
kestore_password="pass@word"
temp_cert_path="/data/cert/temp_cert_file.cer"
cert_alias="root";
command="keytool -importcert -file $temp_cert_path -keystore $keystore_file_path -alias $cert_alias -keypass $kestore_password -storepass $kestore_password -noprompt"
$("$command")
}
This is the output of function execution
pz-active-user# /usr/certmgmt.sh update_keystore
usr/certmgmt.sh: line 1381: keytool -importcert -file /data/cert/temp_cert_file.cer -keystore /data/cert/keystore.jks -alias root -keypass pass@word -storepass pass@word -noprompt: No such file or directory
But if I run this directly from the terminal, it works.
pz-active-user# keytool -importcert -file /data/cert/temp_cert_file.cer -keystore /data/cert/keystore.jks -alias root -keypass pass@word -storepass pass@word -noprompt
Upvotes: 0
Views: 137
Reputation: 361675
Get rid of the command
variable and the $(...)
command substitution. You can call keytool
directly like you did at the command line:
update_keystore() {
keystore_file_path="/data/cert/keystore.jks"
keystore_password="pass@word"
temp_cert_path="/data/cert/temp_cert_file.cer"
cert_alias="root"
keytool -importcert -file "$temp_cert_path" -keystore "$keystore_file_path" -alias "$cert_alias" -keypass "$keystore_password" -storepass "$keystore_password" -noprompt
}
Upvotes: 2