# Using Ansible how to connect Oracle DB on Linux & run command "show pdb" to display oracle pluggable DB, "shutdown immediate" to stop DB and start DB

**URL:** <https://forum.ansible.com/t/using-ansible-how-to-connect-oracle-db-on-linux-run-command-show-pdb-to-display-oracle-pluggable-db-shutdown-immediate-to-stop-db-and-start-db/38252>\
**Category:** Ansible Developer\
**Created:** [July 22, 2023, 3:16pm UTC](https://forum.ansible.com/t/using-ansible-how-to-connect-oracle-db-on-linux-run-command-show-pdb-to-display-oracle-pluggable-db-shutdown-immediate-to-stop-db-and-start-db/38252 "2023-07-22T15:16:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Learner](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@Learner](https://forum.ansible.com/u/Learner)\
**Post date:** [July 22, 2023, 3:16pm UTC](https://forum.ansible.com/t/using-ansible-how-to-connect-oracle-db-on-linux-run-command-show-pdb-to-display-oracle-pluggable-db-shutdown-immediate-to-stop-db-and-start-db/38252/1 "2023-07-22T15:16:07Z")

</div>

Hi All,  
[Using Ansible how to connect Oracle DB on Linux & run command “show pdb” to display oracle pluggable DB, “shutdown immediate” to stop DB and start DB](https://stackoverflow.com/questions/76742454/using-ansible-how-to-connect-oracle-db-on-linux-run-command-show-pdb-to-disp).

Code: - name: Run show pdbs  
shell: |  
{{ oracle\_home }}/bin/sqlplus / as sysdba \<\<EOF  
show pdbs;  
exit  
EOF  
register: query\_output

- name: Display query output  
debug:  
msg: “{{ query\_output.stdout\_lines }}”

Its getting failed with below error:

fatal: [10.192.90.43]: FAILED! =\> {“changed”: true, “cmd”: “"{‘stderr\_lines’: , u’changed’: True, u’end’: u’2023-07-22 15:05:49.418929’, ‘failed’: False, u’stdout’: u’/u01/app/oracle/product/19.3.0.0/db\_1’, u’cmd’: u"cat /etc/oratab | egrep -v ‘^#|^$’ | grep -v ASM | cut -d ‘:’ -f2", u’rc’: 0, u’start’: u’2023-07-22 15:05:49.413535’, u’stderr’: u’‘, u’delta’: u’0:00:00.005394’, ‘stdout\_lines’: [u’/u01/app/oracle/product/19.3.0.0/db\_1’]}/bin/sqlplus / as sysdba \<\<EOF\nshow pdbs;\nexit\nEOF"\n”, “delta”: “0:00:00.005358”, “end”: “2023-07-22 15:05:52.954037”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2023-07-22 15:05:52.948679”, “stderr”: “/bin/sh: {‘stderr\_lines’: , u’changed’: True, u’end’: u’2023-07-22 15:05:49.418929’, ‘failed’: False, u’stdout’: u’/u01/app/oracle/product/19.3.0.0/db\_1’, u’cmd’: ucat: No such file or directory\ncut: fields are numbered from 1\nTry ‘cut --help’ for more information.”, “stderr\_lines”: [“/bin/sh: {‘stderr\_lines’: , u’changed’: True, u’end’: u’2023-07-22 15:05:49.418929’, ‘failed’: False, u’stdout’: u’/u01/app/oracle/product/19.3.0.0/db\_1’, u’cmd’: ucat: No such file or directory”, “cut: fields are numbered from 1”, “Try ‘cut --help’ for more information.”], “stdout”: “”, “stdout\_lines”: }

---

<div class="post-metadata">

**Author:** ![Learner](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@Learner](https://forum.ansible.com/u/Learner)\
**Post date:** [July 23, 2023, 5:07pm UTC](https://forum.ansible.com/t/using-ansible-how-to-connect-oracle-db-on-linux-run-command-show-pdb-to-display-oracle-pluggable-db-shutdown-immediate-to-stop-db-and-start-db/38252/2 "2023-07-23T17:07:13Z")

</div>

Anyone please guide.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 24, 2023, 1:14pm UTC](https://forum.ansible.com/t/using-ansible-how-to-connect-oracle-db-on-linux-run-command-show-pdb-to-display-oracle-pluggable-db-shutdown-immediate-to-stop-db-and-start-db/38252/3 "2023-07-24T13:14:24Z")

</div>

Several things seem to be off with your output, it looks like a  
recursive copy into itself, aside from that, the base error does not  
seem to match the commands shown:

'cmd': ucat: No such file or directory", "cut: fields are numbered  
from 1", "Try 'cut --help' for more information.

Looks like typo in a shell command/script (meant `cat`?) or `ucat` is  
not in the PATH

---

<div class="post-metadata">

**Author:** ![Learner](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@Learner](https://forum.ansible.com/u/Learner)\
**Post date:** [July 25, 2023, 6:55am UTC](https://forum.ansible.com/t/using-ansible-how-to-connect-oracle-db-on-linux-run-command-show-pdb-to-display-oracle-pluggable-db-shutdown-immediate-to-stop-db-and-start-db/38252/4 "2023-07-25T06:55:07Z")

</div>

Thank you for the response. what is the correct code I have to use?
