Hi I'm trying to create a basic script that pauses for user input to verify a file name before generating the output.
I have numerous SSL certificate files which I am trying to determine the expiry date so what I'm trying to do is write a script so that is pauses to request the name of the .pem file and then checks that the file within the directory then runs the command against that file to output the Certificate info. This is what I'm looking for.
#!/bin/bash
#
# This Script Will Check the Validity Of an SSL CERT
echo "Please Enter Name Of .pem File To Be Checked [ENTER]:"
echo
echo
[Checks That File Exists....
if exists then
openssl x509 -text -in {name of .pem file user has input}
if file doesn't exist then
print .pem file doesn't exist
exit
echo -n "Please Enter Name Of .pem File To Be Checked [ENTER]: "
read file
if [ -f "$file" ]; then
openssl x509 -text -in "$file"
else
echo "File Doesn't Exist: $file"
exit # from shell script
fi
This works exactly as I needed ...
Now all I need is to be able to continue to check others without exiting the script every time, so after checking the first one I need a question?
Do you wish to check another [y/n]
If the answer is 'y'
Then Go Back to Beginning
Else exit
while [ 1 -eq 1 ]; do
echo -n "Please Enter Name Of .pem File To Be Checked [ENTER]: "
read file
if [ -f "$file" ]; then
openssl x509 -text -in "$file"
else
echo "File Doesn't Exist: $file"
fi
echo -n "Do you wish to check another [y/n]: "
read yn
if [ "$yn" != "y" ]; then
exit # from shell script
fi
done