Home » Infrastructure » Windows » How do I pass in double quotation argument from dos to rman? (11.2.0.4 windows 2012 r2 Data Center)
How do I pass in double quotation argument from dos to rman? [message #671634] Mon, 10 September 2018 21:52 Go to next message
juniordbanewbie
Messages: 250
Registered: April 2014
Senior Member
Dear all,

my rman script (rman_list_database_backup_by_comp_date.txt) is as follow:


SET ECHO ON

LIST BACKUP OF DATABASE COMPLETED BETWEEN "&1" AND "&2";

SET ECHO OFF

EXIT



when I try to pass from dos to rman the, the date format double quotes are not passed. could anyone tell me how to pass in double quotation argument from dos to rman?


rman target / @rman_list_database_backup_by_comp_date.txt 'to_date("20180826 15:00:00","YYYYMMDD HH24:MI:SS")'

RMAN> SET ECHO ON
2>
3> LIST BACKUP OF DATABASE COMPLETED BETWEEN "to_date(20180826 15:00:00,YYYYMMDD
 HH24:MI:SS)" AND "
Enter value for 2:



alternative method

rman target / @rman_list_database_backup_by_comp_date.txt 'to_date(^"20180826 15:00:00^",^"YYYYMMDD HH24:MI:SS^")'

RMAN> SET ECHO ON
2>
3> LIST BACKUP OF DATABASE COMPLETED BETWEEN "to_date(20180826 15:00:00,YYYYMMDD
 HH24:MI:SS)" AND "
Enter value for 2:

thanks a lot
Re: How do I pass in double quotation argument from dos to rman? [message #671635 is a reply to message #671634] Tue, 11 September 2018 00:53 Go to previous messageGo to next message
John Watson
Messages: 8960
Registered: January 2010
Location: Global Village
Senior Member
It works for me. For example:
C:\Users\john>
C:\Users\john>copy con rman_list_database_backup_by_comp_date.txt
SET ECHO ON

LIST BACKUP OF DATABASE COMPLETED BETWEEN "&1" AND "&2";

SET ECHO OFF

EXIT
^Z
        1 file(s) copied.

C:\Users\john>rman target / @rman_list_database_backup_by_comp_date.txt

Recovery Manager: Release 18.0.0.0.0 - Production on Tue Sep 11 06:49:57 2018
Version 18.3.0.0.0

Copyright (c) 1982, 2018, Oracle and/or its affiliates.  All rights reserved.

PL/SQL package SYS.DBMS_BACKUP_RESTORE version 18.01.00.00 in TARGET database is not current
PL/SQL package SYS.DBMS_RCVMAN version 18.01.00.00 in TARGET database is not current
connected to target database: CDBY:PDBY1 (DBID=1065137282)

RMAN> SET ECHO ON
2>
3> LIST BACKUP OF DATABASE COMPLETED BETWEEN "
Enter value for 1: to_date('20180908','yyyymmdd')
to_date('20180908','yyyymmdd')" AND "
Enter value for 2: sysdate-1
sysdate-1";
4>
5> SET ECHO OFF
6>
7> EXIT
echo set on

using target database control file instead of recovery catalog
specification does not match any backup in the repository

echo set off

Recovery Manager complete.

C:\Users\john>
Re: How do I pass in double quotation argument from dos to rman? [message #671656 is a reply to message #671635] Wed, 12 September 2018 00:23 Go to previous messageGo to next message
juniordbanewbie
Messages: 250
Registered: April 2014
Senior Member
Dear John,

you are right, but you are missing my point here.

in linux I can do the following:

[oracle@ol72-12102-ee ~]$ rman checksyntax @$HOME/dba/scripts/backup/list/list_database_backup/list_database_backup_by_completion_date/rman_list_database_backup_by_completion_date.txt '"to_date('"'"'2018-08-26 15:00:00'"'"','"'"'YYYY-MM-DD HH24:MI:SS'"'"')"' '"to_date('"'"'2018-08-27 15:00:00'"'"','"'"'YYYY-MM-DD HH24:MI:SS'"'"')"'

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Sep 12 13:11:09 2018

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

RMAN> SET ECHO ON
2>
3> LIST BACKUP OF DATABASE COMPLETED BETWEEN "to_date('2018-08-26 15:00:00','YYYY-MM-DD HH24:MI:SS')" AND "to_date('2018-08-27 15:00:00','YYYY-MM-DD HH24:MI:SS')";
4>
5> SET ECHO OFF
6>
7> EXIT
The cmdfile has no syntax errors

Recovery Manager complete.


to escape a quote within a single quote

https://stackoverflow.com/questions/1250079/how-to-escape-single-quotes-within-single-quoted-strings
Quote:


alias rxvt='urxvt -fg '"'"'#111111'"'"' -bg '"'"'#111111'"'"
# ^^^^^ ^^^^^ ^^^^^ ^^^^
# 12345 12345 12345 1234

Explanation of how '"'"' is interpreted as just ':

' End first quotation which uses single quotes.
" Start second quotation, using double-quotes.
' Quoted character.
" End second quotation, using double-quotes.
' Start third quotation, using single quotes.


do you notice that I passed in all the arguments before entering them inside rman?

but the same cannot be said for MS dos environment.

the whole purpose of having a dynamic rman script or sqlplus script is so that the dynamic script can be reused again on any platform. Based on my experience I have harder time doing dos scripting compare to shell scripting.

even the following url

Quote:

http://www.robvanderwoude.com/escapechars.php
doesn't help me much.
Re: How do I pass in double quotation argument from dos to rman? [message #671658 is a reply to message #671656] Wed, 12 September 2018 01:16 Go to previous messageGo to next message
John Watson
Messages: 8960
Registered: January 2010
Location: Global Village
Senior Member
Until you show an error, I can't see a problem. Sorry, man.

Re: How do I pass in double quotation argument from dos to rman? [message #671659 is a reply to message #671634] Wed, 12 September 2018 01:48 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
C:\>(for %i in ("to_date('20180826 15:00:00','YYYYMMDD HH24:MI:SS')" sysdate) do @echo %~i) |
More? rman target / @C:\rman_list_database_backup_by_comp_date.txt

Recovery Manager: Release 11.2.0.4.0 - Production on Mer. Sept. 12 08:44:56 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: MIKB2 (DBID=288523517)

RMAN> SET ECHO ON
2>
3> LIST BACKUP OF DATABASE COMPLETED BETWEEN "
Enter value for 1: to_date('20180826 15:00:00','YYYYMMDD HH24:MI:SS') " AND "
Enter value for 2: sysdate ";
4>
5> SET ECHO OFF
6>
7> EXIT
echo set on

using target database control file instead of recovery catalog
specification does not match any backup in the repository

echo set off

Recovery Manager complete.
Re: How do I pass in double quotation argument from dos to rman? [message #671697 is a reply to message #671659] Fri, 14 September 2018 00:41 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Any feedback?

Re: How do I pass in double quotation argument from dos to rman? [message #671709 is a reply to message #671697] Sat, 15 September 2018 05:06 Go to previous messageGo to next message
juniordbanewbie
Messages: 250
Registered: April 2014
Senior Member
Dear all,

the following is the wrong way to invoke date arguments in dos


C:>rman checksyntax @C:\rman_list_database_backup_by_completion_date.txt '"to_date('"'"'2018-08-26
 15:00:00'"'"','"'"'YYYY-MM-DD HH24:MI:SS'"'"')"'

Argument     Value          Description
-----------------------------------------------------------------------------
target       quoted-string  connect-string for target database
catalog      quoted-string  connect-string for recovery catalog
nocatalog    none           if specified, then no recovery catalog
cmdfile      quoted-string  name of input command file
log          quoted-string  name of output message log file
trace        quoted-string  name of output debugging message log file
append       none           if specified, log is opened in append mode
debug        optional-args  activate debugging
msgno        none           show RMAN-nnnn prefix for all messages
send         quoted-string  send a command to the media manager
pipe         string         building block for pipe names
timeout      integer        number of seconds to wait for pipe input
checksyntax  none           check the command file for syntax errors
-----------------------------------------------------------------------------
Both single and double quotes (' or ") are accepted for a quoted-string.
Quotes are not required unless the string contains embedded white-space.

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00552: syntax error in command line arguments
RMAN-01006: error signaled during parse
RMAN-02001: unrecognized punctuation symbol "-"

Dear Michel,
here's the outcome
C:>(for %i in ("to_date('20180826 15:00
:00','YYYYMMDD HH24:MI:SS')" sysdate) do @echo %~i) | rman target / @C:\rman_list_database_backup_by_completion_date.txt

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Sep 15 17:25:19 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: KORCL (DBID=2228540098, not open)

RMAN> SET ECHO ON
2>
3> LIST BACKUP OF DATABASE COMPLETED BETWEEN "
Enter value for 1: to_date('20180826 15:00:00','YYYYMMDD HH24:MI:SS') " AND "
Enter value for 2: sysdate ";
4>
5> SET ECHO OFF
6>
7> EXIT
echo set on


thanks you providing the correct way of passing argument to rman in dos.
Re: How do I pass in double quotation argument from dos to rman? [message #671725 is a reply to message #671709] Sat, 15 September 2018 13:46 Go to previous message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Thank for the feedback.

Previous Topic: Archiving to a shared directory
Next Topic: INSERT INTO RETURNING
Goto Forum:
  


Current Time: Thu Nov 21 05:34:42 CST 2024