0

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
1

1 Answer 1

2

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
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.