# how to run the below bash file on f5

**URL:** <https://community.f5.com/t/how-to-run-the-below-bash-file-on-f5/72715>\
**Category:** DevCentral Connects\
**Tags:** script\
**Created:** [July 15, 2023, 12:32pm UTC](https://community.f5.com/t/how-to-run-the-below-bash-file-on-f5/72715 "2023-07-15T12:32:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralph\_ralf](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@ralph\_ralf](https://community.f5.com/u/ralph_ralf)\
**Post date:** [July 15, 2023, 12:32pm UTC](https://community.f5.com/t/how-to-run-the-below-bash-file-on-f5/72715/1 "2023-07-15T12:32:37Z")

</div>

Hello,

I would like to extract a list of all virtual servers , profiles and certificates on my F5 ; I found the below script but I dont know how to run it on f5.Where should I place the cert-mapping file ? In which folder on f5 ?

- Log on to the BIG-IP command line.

- Using a text editor, create the **cert-mapping** file.

- Place the following **bash** script contents in the **cert-mapping** file:

- Close the text editor saving&nbsp;the file&nbsp; **cert-mapping** &nbsp;that contains the bash script.

- To execute the script type the following command:

Thansk in advance.

Best Regards,

---

<div class="post-metadata">

**Author:** ![KeesvandenBos](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@KeesvandenBos](https://community.f5.com/u/KeesvandenBos)\
**Post date:** [July 15, 2023, 6:04pm UTC](https://community.f5.com/t/how-to-run-the-below-bash-file-on-f5/72715/2 "2023-07-15T18:04:32Z")

</div>

Hi Ralph,

If you only need it to run once you can place it in /tmp/.  
/shared/scripts would be a nice location of you are going to run it multiple times during the life of your BIG-IP.

Do not forget to make it executable. (chmod u+x cert-mapping)

Cheers,  
Kees

---

<div class="post-metadata">

**Author:** ![ralph\_ralf](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@ralph\_ralf](https://community.f5.com/u/ralph_ralf)\
**Post date:** [July 15, 2023, 7:58pm UTC](https://community.f5.com/t/how-to-run-the-below-bash-file-on-f5/72715/3 "2023-07-15T19:58:06Z")

</div>

Thanks for your reply :

Ive created the notepad file and transfered it to /tmp folder using filezilla.Then Ive changed the file to be an executable as advised.However after running it I got an error.

Can you have a look on the below output and revert back.Thanks in advance

[root@f5-IB-2:Standby:In Sync] tmp # chmod u+x cert-mapping  
[root@f5-IB-2:Standby:In Sync] tmp #  
[root@f5-IB-2:Standby:In Sync] tmp #  
[root@f5-IB-2:Standby:In Sync] tmp # ls -l  
total 580  
-r--r--r--. 1 root root 261660 2021-05-08 07:24 BigDB.dat.orig  
-rwxr--r--. 1 root root 914 2023-07-15 22:54 cert-mapping  
-r--r--r--. 1 root root 131 2022-08-20 22:57 dhclient.sh  
drwxr-xr-x. 2 root root 1024 2023-07-15 06:38 epsec  
-r--r--r--. 1 root root 206 2022-08-20 22:57 hosts\_script  
drwxr-xr-x. 2 root root 1024 2022-08-27 03:33 hsperfdata\_root  
drwxr-xr-x. 2 tomcat tomcat 1024 2022-08-20 22:58 hsperfdata\_tomcat  
-rw-r--r--. 1 root webusers 304730 2023-07-15 22:49 running-config  
-rw-------. 1 apache apache 451 2023-07-15 15:08 sess\_blttcb605qqnb26s65sg5v1jv2  
-rw-------. 1 apache apache 451 2023-07-15 15:08 sess\_ec2mp7g390lvpeg07hcth2ap02  
-rw-------. 1 apache apache 451 2023-07-15 15:08 sess\_n781lbebpi5ndb6ae7fa18m1q7  
-r--r--r--. 1 root root 355 2022-08-20 22:57 sshd\_login.sh  
[root@f5-IB-2:Standby:In Sync] tmp #  
[root@f5-IB-2:Standby:In Sync] tmp #  
[root@f5-IB-2:Standby:In Sync] tmp # bash ./cert-mapping  
Virtual: Profile: Certificate: Ciphers:  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
'/cert-mapping: line 7: syntax error near unexpected token `do  
'/cert-mapping: line 7: `do  
[root@f5-IB-2:Standby:In Sync] tmp #

---

<div class="post-metadata">

**Author:** ![KeesvandenBos](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@KeesvandenBos](https://community.f5.com/u/KeesvandenBos)\
**Post date:** [July 16, 2023, 8:08pm UTC](https://community.f5.com/t/how-to-run-the-below-bash-file-on-f5/72715/4 "2023-07-16T20:08:04Z")

</div>

Notepad isn’t your best option. Are you able to save the file locally with notepad++

Also, can you post a cat from the file?

Command on the cli is cat /temp/cert-mapping

---

<div class="post-metadata">

**Author:** ![ralph\_ralf](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@ralph\_ralf](https://community.f5.com/u/ralph_ralf)\
**Post date:** [July 17, 2023, 6:20am UTC](https://community.f5.com/t/how-to-run-the-below-bash-file-on-f5/72715/5 "2023-07-17T06:20:23Z")

</div>

Dear KeesvandenBos,

I 've edited the same script into notepad ++ as recommended and the file now is compatible with unix bash.

I was also able to cat /tmp/cert-mapping.bash (below):

The question now how can I run it ? tmsh ? bash ./cert-mapping is not working ?

[root@f5-IB-2:Standby:In Sync] config #  
^[[A[root@f5-IB-2:Standby:In Sync] config # cat /tmp/cert-mapping.bash  
#!/bin/bash  
# Search /config and sub directories (partitions) for bigip.conf files  
LIST=`find /config -name bigip.conf | xargs awk ‘$2 == “virtual” {print $3}’ 2\> /dev/null | sort -u`  
echo “Virtual: Profile: Certificate: Ciphers:”  
echo “\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_”  
for VAL in ${LIST}  
do  
PROF=`tmsh show /ltm virtual ${VAL} profiles 2\> /dev/null | grep -B 1 " Ltm::ClientSSL Profile:" | cut -d: -f4 | grep -i “[a-z]” | sed s’/ //'g| sort -u`  
test -n “${PROF}” 2\>&- && {  
VIRTS=`expr $VIRTS + 1`  
for PCRT in ${PROF}  
do  
CERT=`tmsh list /ltm profile client-ssl ${PCRT} | awk ‘$1 == “cert” {print $2}’ 2\> /dev/null | sort -u`  
test -n “${CERT}” 2\>&- && {  
CIPHERS=`tmsh list /ltm profile client-ssl ${PCRT} ciphers | grep ciphers | awk ‘{print $2}’`  
echo “${VAL} ${PCRT} ${CERT} ${CIPHERS}”  
}  
done  
}  
done  
echo “Virtual server count: ${VIRTS}”[root@f5-IB-2:Standby:In Sync] config #  
[root@f5-IB-2:Standby:In Sync] config #  
[root@f5-IB-2:Standby:In Sync] config #

---

<div class="post-metadata">

**Author:** ![KeesvandenBos](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@KeesvandenBos](https://community.f5.com/u/KeesvandenBos)\
**Post date:** [July 17, 2023, 8:08am UTC](https://community.f5.com/t/how-to-run-the-below-bash-file-on-f5/72715/6 "2023-07-17T08:08:08Z")

</div>

[root@f5-IB-2:Standby:In Sync] config #cd /tmp  
[root@f5-IB-2:Standby:In Sync] tmp #./cert-mapping
