# How to pass the value of variable created by register from shell module to oracle RMAN

**URL:** <https://forum.ansible.com/t/how-to-pass-the-value-of-variable-created-by-register-from-shell-module-to-oracle-rman/38322>\
**Category:** Ansible Project\
**Created:** [August 11, 2023, 1:46pm UTC](https://forum.ansible.com/t/how-to-pass-the-value-of-variable-created-by-register-from-shell-module-to-oracle-rman/38322 "2023-08-11T13:46:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luiz\_Gustavo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/luiz_gustavo/32/4846_2.png) [@Luiz\_Gustavo](https://forum.ansible.com/u/Luiz_Gustavo)\
**Post date:** [August 11, 2023, 1:46pm UTC](https://forum.ansible.com/t/how-to-pass-the-value-of-variable-created-by-register-from-shell-module-to-oracle-rman/38322/1 "2023-08-11T13:46:12Z")

</div>

Hey guys.

I’m passing commands to rman through a variable created by the shell module.

Where am I going wrong?

…

- name: Creates purge script from the original script  
shell: egrep -i ‘connect|delete’ “{{ script\_path }}” | sed ‘/^#/d;/delete/I s/[0-9]{1,}/1/’  
register: script\_path\_tmp

- name: Print var  
debug:  
msg: “{{ script\_path\_tmp.stdout\_lines }}”

- name: Runs RMAN archivelog purge script  
shell:  
cmd: |  
{{ env\_orahome }}/bin/rman \<\< EOF  
“{{ script\_path\_tmp.stdout\_lines }}”  
EOF  
environment:  
ORACLE\_HOME: “{{ env\_orahome }}”  
register: rman\_out

# Result of execution:

TASK [Print var] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [hostname] =\> {  
“msg”: [  
“CONNECT TARGET "USER/pass@service as sysbackup"”,  
“DELETE NOPROMPT ARCHIVELOG ALL BACKED UP 1 TIMES TO DEVICE TYPE sbt;”  
]  
}

TASK [Runs RMAN archivelog purge script] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [hostname]: FAILED! =\> {“changed”: true, “cmd”: “/u01/app/oracle/product/[19.0.0.0/dbhome\_1/bin/rman](http://19.0.0.0/dbhome_1/bin/rman) \<\< EOF\n "[u’CONNECT TARGET "USER/pass@service as sysbackup"‘, u’DELETE NOPROMPT ARCHIVELOG ALL BACKED UP 1 TIMES TO DEVICE TYPE sbt;’]"\nEOF\n”, “delta”: “0:00:00.552187”, “end”: “2023-08-11 10:22:21.657952”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2023-08-11 10:22:21.105765”, “stderr”: “”, “stderr\_lines”: , “stdout”: “\nRecovery Manager: Release 19.0.0.0.0 - Production on Fri Aug 11 10:22:21 2023\nVersion 19.16.0.0.0\n\nCopyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.\n\nRMAN\> \nRMAN-00571: ===========================================================\nRMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============\nRMAN-00571: ===========================================================\nRMAN-00558: error encountered while parsing input commands\nRMAN-01009: syntax error: found "double-quoted-string": expecting one of: "advise, allocate, alter, analyze, associate statistics, audit, backup, begin, @, call, catalog, change, comment, commit, configure, connect, convert, copy, create, create catalog, create global, create or replace global, create or replace script, create script, crosscheck, declare, delete, delete from, describe, describe catalog, disassociate statistics, drop, drop catalog, drop database, duplicate, exit, explain plan, flashback, flashback table, grant, grant catalog, grant register, host, import, insert, list, lock, merge, mount, noaudit, open, print, purge, quit, recover, register, release"\nRMAN-01007: at line 1 column 3 file: standard input\n\nRMAN\> \n\nRecovery Manager complete.”, “stdout\_lines”: [“”, “Recovery Manager: Release 19.0.0.0.0 - Production on Fri Aug 11 10:22:21 2023”, “Version 19.16.0.0.0”, “”, “Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.”, “”, "RMAN\> ", “RMAN-00571: ===========================================================”, “RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============”, “RMAN-00571: ===========================================================”, “RMAN-00558: error encountered while parsing input commands”, “RMAN-01009: syntax error: found "double-quoted-string": expecting one of: "advise, allocate, alter, analyze, associate statistics, audit, backup, begin, @, call, catalog, change, comment, commit, configure, connect, convert, copy, create, create catalog, create global, create or replace global, create or replace script, create script, crosscheck, declare, delete, delete from, describe, describe catalog, disassociate statistics, drop, drop catalog, drop database, duplicate, exit, explain plan, flashback, flashback table, grant, grant catalog, grant register, host, import, insert, list, lock, merge, mount, noaudit, open, print, purge, quit, recover, register, release"”, “RMAN-01007: at line 1 column 3 file: standard input”, “”, "RMAN\> ", “”, “Recovery Manager complete.”]}

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [August 16, 2023, 10:55am UTC](https://forum.ansible.com/t/how-to-pass-the-value-of-variable-created-by-register-from-shell-module-to-oracle-rman/38322/2 "2023-08-16T10:55:03Z")

</div>

Remove the double-quotes from

shell:  
cmd: |  
{{ env\_orahome }}/bin/rman \<\< EOF  
“{{ script\_path\_tmp.stdout\_lines }}”  
EOF

---

<div class="post-metadata">

**Author:** ![Luiz\_Gustavo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/luiz_gustavo/32/4846_2.png) [@Luiz\_Gustavo](https://forum.ansible.com/u/Luiz_Gustavo)\
**Post date:** [August 16, 2023, 5:03pm UTC](https://forum.ansible.com/t/how-to-pass-the-value-of-variable-created-by-register-from-shell-module-to-oracle-rman/38322/3 "2023-08-16T17:03:13Z")

</div>

It worked as follows, removing and considering e stdout:

shell:  
cmd: |  
{{ env\_orahome }}/bin/rman \<\< EOF  
{{ script\_path\_tmp.stdout }}  
EOF

Thanks Todd.
